Skip to content

@swc/wasm delaying process shutdown #1352

Open

Description

Describe the bug

@swc/wasm appears to delay the graceful shutdown of a node process once it's loaded.

Input code

node -e 'require("@swc/wasm"); console.log("done.  Should ideally terminate immediately but is somehow delayed by @swc/wasm")'

The node process remains running for about 5 seconds after the log statement. I'm not sure if @swc/wasm is setting some sort of timer or why the process is staying up.

Expected behavior

node process gracefully terminates immediately after the log statement.

Version
The version of @swc/wasm: 1.2.45
OS: Ubuntu Linux
node: v14.15.3

Activity

  1. Brooooooklyn commented on Jan 23, 2021

    @Brooooooklyn
    Member

    I think this may be a wasm problem, wasm needs to be read, loaded and parsed asynchronously, and perhaps this process cannot be interrupted

  2. cspotcode commented on Jan 23, 2021

    @cspotcode
    ContributorAuthor

    I don't think that is the issue, because I can invoke transformSync to prove that the WASM is executable much earlier. Also, if it were an issue with async compilation, that would mean that WASM takes a full 5 seconds to load, which I think we can agree seems very wrong.

    Here is the updated reproduction. It uses transformSync, then logs the date. Then the process waits 5 seconds before terminating, at which point a subsequent process logs the date again. This shows the magnitude of the delay.

    node -e 'console.log(require("@swc/wasm").transformSync("const foo = 123", {})); console.log(new Date)' ; node -e 'console.log(new Date)'
    

    Sample output:

    2021-01-23T21:41:57.192Z
    2021-01-23T21:42:01.869Z
    
  3. yisibl commented on Jan 5, 2023

    @yisibl
    Contributor

    It looks like it's been greatly improved in Node.js 18.3.0, so you can try it out.
    nodejs/node#36616 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions