Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9ce788e

Browse filesBrowse files
pd4d10targos
authored andcommitted
process: fix promise catching
Fixes: #30953 PR-URL: #30957 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 9e5d39c commit 9ce788e
Copy full SHA for 9ce788e

File tree

Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/process/promises.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/promises.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ function handledRejection(promise) {
123123
return;
124124
}
125125
}
126-
setHasRejectionToWarn(false);
126+
if (maybeUnhandledPromises.size === 0 && asyncHandledRejections.length === 0)
127+
setHasRejectionToWarn(false);
127128
}
128129

129130
const unhandledRejectionErrName = 'UnhandledPromiseRejectionWarning';
Collapse file

‎test/parallel/test-promises-unhandled-rejections.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-promises-unhandled-rejections.js
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,3 +718,15 @@ asyncTest(
718718
let timer = setTimeout(common.mustNotCall(), 10000);
719719
},
720720
);
721+
722+
// https://github.com/nodejs/node/issues/30953
723+
asyncTest(
724+
'Catching a promise should not take effect on previous promises',
725+
function(done) {
726+
onUnhandledSucceed(done, function(reason, promise) {
727+
assert.strictEqual(reason, '1');
728+
});
729+
Promise.reject('1');
730+
Promise.reject('2').catch(function() {});
731+
}
732+
);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.