Skip to content

Commit a41876c

Browse files
authored
Use stderr directly to write errors in worker.js under node. NFC (#16161)
Writing directly to stderr works even when the main thread is currently blocked (not returning to its message loop), for example in pthread_join. We already do this in shell.sh when defining `err` in the primary module code. This issue was causing error messages from the worker to be lost in the repro case posted in #16021.
1 parent f99af02 commit a41876c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/worker.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ function assert(condition, text) {
6363

6464
function threadPrintErr() {
6565
var text = Array.prototype.slice.call(arguments).join(' ');
66+
#if ENVIRONMENT_MAY_BE_NODE
67+
// See https://github.com/emscripten-core/emscripten/issues/14804
68+
if (ENVIRONMENT_IS_NODE) {
69+
fs.writeSync(2, text + '\n');
70+
return;
71+
}
72+
#endif
6673
console.error(text);
6774
}
6875
function threadAlert() {

0 commit comments

Comments
 (0)