Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@swc/wasm delaying process shutdown #1352

Open
cspotcode opened this issue Jan 22, 2021 · 3 comments
Open

@swc/wasm delaying process shutdown #1352

cspotcode opened this issue Jan 22, 2021 · 3 comments
Labels

Comments

@cspotcode
Copy link
Contributor

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

@Brooooooklyn
Copy link
Member

Brooooooklyn commented Jan 23, 2021

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

@cspotcode
Copy link
Contributor Author

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

@yisibl
Copy link
Contributor

yisibl commented Jan 5, 2023

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
Labels
Development

No branches or pull requests

3 participants