Skip to content

Commit 144233b

Browse files
islandryumarco-ippolito
authored andcommitted
process: fix wrong asyncContext under unhandled-rejections=strict
Fixes: #60034 PR-URL: #60103 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
1 parent b1da374 commit 144233b

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

‎lib/internal/process/promises.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ function strictUnhandledRejectionsMode(promise, promiseInfo, promiseAsyncId){
340340
reason : newUnhandledPromiseRejection(reason);
341341
// This destroys the async stack, don't clear it after
342342
triggerUncaughtException(err,true/* fromPromise */);
343-
if(promiseAsyncId===undefined){
343+
if(promiseAsyncId!==undefined){
344344
pushAsyncContext(
345345
promise[kAsyncIdSymbol],
346346
promise[kTriggerAsyncIdSymbol],
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Flags: --unhandled-rejections=strict
2+
'use strict';
3+
4+
constcommon=require('../common');
5+
constfs=require('fs');
6+
constassert=require('assert');
7+
8+
process.on('unhandledRejection',common.mustNotCall);
9+
10+
process.on('uncaughtException',common.mustCall((err)=>{
11+
assert.ok(err.message.includes('foo'));
12+
}));
13+
14+
15+
asyncfunctionreadFile(){
16+
returnfs.promises.readFile(__filename);
17+
}
18+
19+
asyncfunctioncrash(){
20+
thrownewError('foo');
21+
}
22+
23+
24+
asyncfunctionmain(){
25+
crash();
26+
readFile();
27+
}
28+
29+
main();

0 commit comments

Comments
(0)