Skip to content

Sequentialize uncaught exceptions in Node.js Workers - #25041

Merged
juj merged 8 commits into
emscripten-core:mainfrom
juj:fix_flaky_test_pthread_abort
Aug 25, 2025
Merged

Sequentialize uncaught exceptions in Node.js Workers#25041
juj merged 8 commits into
emscripten-core:mainfrom
juj:fix_flaky_test_pthread_abort

Conversation

@juj

@juj juj commented Aug 25, 2025

Copy link
Copy Markdown
Collaborator

Sequentialize uncaught exceptions in Node.js Workers into the same postMessage() stream that other messages go through, to ensure they are received by the main thread in the order they were generated.

Fixes #15014.

See nodejs/node#59617.

@juj
juj force-pushed the fix_flaky_test_pthread_abort branch 2 times, most recently from 848ca23 to f422942 Compare August 25, 2025 10:02
…stMessage() stream that other messages go through, to ensure they are received by the main thread in the order they were generated. Fixes emscripten-core#15014. See nodejs/node#59617

Ruff
@juj
juj force-pushed the fix_flaky_test_pthread_abort branch from f422942 to cefd3ed Compare August 25, 2025 11:13

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if I'm understanding correctly, issue is with the onAbort handler, which is being called via the callHandler message is racing with the onerror handler for uncaught exceptions?

Nice work find this!

Comment thread src/runtime_common.js Outdated
@juj

juj commented Aug 25, 2025

Copy link
Copy Markdown
Collaborator Author

So if I'm understanding correctly, issue is with the onAbort handler, which is being called via the callHandler message is racing with the onerror handler for uncaught exceptions?

Nice work find this!

Thanks - that looks like the case. For some reason Node.js internally uses a different mechanism to propagate postMessage()s vs process.on('uncaughtError')s from Worker to parent.

Comment thread src/lib/libpthread.js Outdated
@juj
juj enabled auto-merge (squash) August 25, 2025 19:06
@juj
juj force-pushed the fix_flaky_test_pthread_abort branch from a839349 to 43e00dd Compare August 25, 2025 19:49
@juj
juj disabled auto-merge August 25, 2025 23:35
@juj
juj merged commit 20dd010 into emscripten-core:main Aug 25, 2025
28 of 30 checks passed
inolen pushed a commit to inolen/emscripten that referenced this pull request Feb 13, 2026
…#25041)

Sequentialize uncaught exceptions in Node.js Workers into the same
postMessage() stream that other messages go through, to ensure they are
received by the main thread in the order they were generated.

Fixes emscripten-core#15014.

See nodejs/node#59617.
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

Successfully merging this pull request may close these issues.

test_pthread_abort is failing on macOS & flaky on linux

2 participants