mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
process: fix wrong asyncContext under unhandled-rejections=strict
Fixes: https://github.com/nodejs/node/issues/60034 PR-URL: https://github.com/nodejs/node/pull/60103 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
This commit is contained in:
parent
ffb25b8ce2
commit
60f1a5d077
|
|
@ -281,7 +281,7 @@ function strictUnhandledRejectionsMode(promise, promiseInfo, promiseAsyncId) {
|
|||
reason : new UnhandledPromiseRejection(reason);
|
||||
// This destroys the async stack, don't clear it after
|
||||
triggerUncaughtException(err, true /* fromPromise */);
|
||||
if (promiseAsyncId === undefined) {
|
||||
if (promiseAsyncId !== undefined) {
|
||||
pushAsyncContext(
|
||||
promise[kAsyncIdSymbol],
|
||||
promise[kTriggerAsyncIdSymbol],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
// Flags: --unhandled-rejections=strict
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const fs = require('fs');
|
||||
const assert = require('assert');
|
||||
|
||||
process.on('unhandledRejection', common.mustNotCall);
|
||||
|
||||
process.on('uncaughtException', common.mustCall((err) => {
|
||||
assert.ok(err.message.includes('foo'));
|
||||
}));
|
||||
|
||||
|
||||
async function readFile() {
|
||||
return fs.promises.readFile(__filename);
|
||||
}
|
||||
|
||||
async function crash() {
|
||||
throw new Error('foo');
|
||||
}
|
||||
|
||||
|
||||
async function main() {
|
||||
crash();
|
||||
readFile();
|
||||
}
|
||||
|
||||
main();
|
||||
Loading…
Reference in New Issue
Block a user