Skip to content

[esm-integration] Sequentialize uncaught exceptions in Node.js workers - #27854

Merged
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:esm_pthread_uncaught_exception
Oct 2, 2026
Merged

sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:esm_pthread_uncaught_exception

Conversation

@sbc100

@sbc100 sbc100 commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

In #25041, uncaught exceptions in Node.js worker threads were captured and sequentialized over the postMessage pipe to resolve a race condition where Node.js delivers worker uncaught exception events before earlier postMessages (such as proxied onAbort handlers). That change fixed #15014 for non-ESM builds.

However, that workaround in src/runtime_common.js was omitted under -sWASM_ESM_INTEGRATION because worker threads bootstrap via src/pthread_esm_startup.mjs instead. As a result, test_pthread_abort remained flaky under esm_integration.

This installs the same process.on('uncaughtException') handler in src/pthread_esm_startup.mjs and removes the @flaky annotation from test_pthread_abort.

See: #15014
Fixes: #25151

In emscripten-core#25041, uncaught exceptions in Node.js worker threads were
captured and sequentialized over the `postMessage` pipe to resolve a
race condition where Node.js delivers worker uncaught exception events
before earlier `postMessage`s (such as proxied `onAbort` handlers).
That change fixed emscripten-core#15014 for non-ESM builds.

However, that workaround in `src/runtime_common.js` was omitted under
`-sWASM_ESM_INTEGRATION` because worker threads bootstrap via
`src/pthread_esm_startup.mjs` instead. As a result,
`test_pthread_abort` remained flaky under `esm_integration`.

This installs the same `process.on('uncaughtException')` handler in
`src/pthread_esm_startup.mjs` and removes the `@flaky` annotation from
`test_pthread_abort`.

See: emscripten-core#15014
Fixes: emscripten-core#25151
@sbc100
sbc100 requested review from juj and kripken October 2, 2026 18:33
@sbc100
sbc100 merged commit 9aad1ec into emscripten-core:main Oct 2, 2026
42 checks passed
@sbc100
sbc100 deleted the esm_pthread_uncaught_exception branch October 2, 2026 20:21
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.

esm_integration.test_stress_pthread_abort fails test_pthread_abort is failing on macOS & flaky on linux

2 participants