Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/process/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
29 changes: 29 additions & 0 deletions test/parallel/test-promise-unhandled-error-with-reading-file.js
Original file line number Diff line number Diff line change
@@ -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