GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — process: fix wrong asyncContext under unhandled-rejections=strict · nodejs/node@144233b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/process
    • promises.js
  • test/parallel
    • test-promise-unhandled-error-with-reading-file.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/process/promises.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/promises.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ function strictUnhandledRejectionsMode(promise, promiseInfo, promiseAsyncId) {
340340
reason : new UnhandledPromiseRejection(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],
Collapse file

‎test/parallel/test-promise-unhandled-error-with-reading-file.js‎

Copy file name to clipboard
+29Lines 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+
const common = require('../common');
5+
const fs = require('fs');
6+
const assert = 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+
async function readFile() {
16+
return fs.promises.readFile(__filename);
17+
}
18+
19+
async function crash() {
20+
throw new Error('foo');
21+
}
22+
23+
24+
async function main() {
25+
crash();
26+
readFile();
27+
}
28+
29+
main();

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.