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: emit unhandled warning immediately · nodejs/node@5bca4c7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/process
    • promises.js
  • test/parallel
    • test-promises-unhandled-rejections.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
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function emitPromiseRejectionWarnings() {
108108
}
109109
}
110110

111-
let hadListeners = false;
111+
let maybeScheduledTicks = false;
112112
let len = pendingUnhandledRejections.length;
113113
while (len--) {
114114
const promise = pendingUnhandledRejections.shift();
@@ -118,10 +118,9 @@ function emitPromiseRejectionWarnings() {
118118
const { reason, uid } = promiseInfo;
119119
if (!process.emit('unhandledRejection', reason, promise)) {
120120
emitWarning(uid, reason);
121-
} else {
122-
hadListeners = true;
123121
}
122+
maybeScheduledTicks = true;
124123
}
125124
}
126-
return hadListeners || pendingUnhandledRejections.length !== 0;
125+
return maybeScheduledTicks || pendingUnhandledRejections.length !== 0;
127126
}
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-promises-unhandled-rejections.js
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,3 +699,22 @@ asyncTest('Rejected promise inside unhandledRejection allows nextTick loop' +
699699
process.nextTick(() => promise.catch(() => done()));
700700
});
701701
});
702+
703+
asyncTest(
704+
'Unhandled promise rejection emits a warning immediately',
705+
function(done) {
706+
clean();
707+
Promise.reject(0);
708+
const { emitWarning } = process;
709+
process.emitWarning = common.mustCall((...args) => {
710+
if (timer) {
711+
clearTimeout(timer);
712+
timer = null;
713+
done();
714+
}
715+
emitWarning(...args);
716+
}, 2);
717+
718+
let timer = setTimeout(common.mustNotCall(), 10000);
719+
},
720+
);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — 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.