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

Loading WASM modules change the NodeJS unhandled-promise-rejection behavior #11768

Closed
yllan opened this issue Jul 31, 2020 · 3 comments
Closed

Comments

@yllan
Copy link

yllan commented Jul 31, 2020

Hi.

I don't even know if this is actually an emscripten bug or node's bug. Just observed some strange behavior.

If I load a wasm module compiled by emscripten in NodeJS 12, the unhandled-promise-rejection behavior is changed: if I comment out line 2, the unhandled-promise-rejection will not terminate the node. However, if I uncomment line 2, it immediately crash the node.

Screen Shot 2020-07-31 at 4 19 40 PM

Screen Shot 2020-07-31 at 4 20 00 PM

Here's a demonstration project:
https://github.com/yllan/unhandled-promise-rejection/

@yllan
Copy link
Author

yllan commented Jul 31, 2020

OK. I've found that's because this line:

  process['on']('uncaughtException', function(ex) {
    // suppress ExitStatus exceptions from showing an error
    if (!(ex instanceof ExitStatus)) {
      throw ex;
    }
  });

  process['on']('unhandledRejection', abort);

But why? What will happened if I delete these handler?

@sbc100
Copy link
Collaborator

sbc100 commented Jul 31, 2020

Some version of node will just exit with 0 in this case. I believe we had issues where failures in testing were going unnoticed because tests returning 0 is signal of success.

It could be that recent versions of node have fixed that.. i seem to remember them promising they would do that.

In the mean time I think you can build with -s NODEJS_CATCH_REJECTION=0 to fix this no?

@yllan
Copy link
Author

yllan commented Aug 3, 2020

Thanks. It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants