Closed
Description
This is the underlying bug that kept my workaround of #37988 from working.
- Version: v15.12.0
- Platform: Linux alex-desktop 5.8.0-48-generic npm install is unbelievably slow, fails in certain environments #54~20.04.1-Ubuntu SMP Sat Mar 20 13:40:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
What steps will reproduce the bug?
index.js
const path = require('path');
const { Worker } = require('worker_threads');
const worker = new Worker(path.join(__dirname, 'worker.js'));
worker
.on('online', () => {
console.log('online');
})
.on('error', (err) => {
console.log('error: %s', err);
})
.on('exit', (code) => {
console.log('exit: %s', code);
process.exit();
});
worker.js
process.on('uncaughtException', function () {
throw new Error('uncaughtException');
});
throw new Error('oopsie');
node index.js
online
error: Error: uncaughtException
at process.<anonymous> (/home/alex/src/issues/worker-exit-code/worker.js:2:9)
at process.emit (events.js:315:20)
at internal/process/execution.js:163:25
at process.workerOnGlobalUncaughtException [as _fatalException] (internal/main/worker_thread.js:194:15)
exit: 0 <================
node worker.js
echo $?
7 <================
How often does it reproduce? Is there a required condition?
10/10 would reproduce again
What is the expected behavior?
Exit code 7
for the worker
Exit code >0
for the worker. Exit codes of workers don't seem to be aligned with the main process, I'm fine with anything other than 0.
What do you see instead?
Exit code 0
, which is why my error handling didn't catch it