node/test/async-hooks/test-unhandled-exception-valid-ids.js
Anatoli Papirovski 51783320a4 process: ignore asyncId 0 in exception handler
Today, the global uncaught exception handler is the only
place where asyncId 0 is not ignored and we still proceed
to call emitAfter. This would've already failed one of
our correctness tests in async_hooks if not for some other
code meant to handle a different edge case.

Fixes: https://github.com/nodejs/node/issues/22982

PR-URL: https://github.com/nodejs/node/pull/41424
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-01-18 22:05:12 +01:00

18 lines
288 B
JavaScript

'use strict';
const common = require('../common');
const initHooks = require('./init-hooks');
const hooks = initHooks();
hooks.enable();
setImmediate(() => {
throw new Error();
});
setTimeout(() => {
throw new Error();
}, 1);
process.on('uncaughtException', common.mustCall(2));