summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnatoli Papirovski <anatoli.papirovski@postmates.com>2018-11-24 12:15:03 -0800
committerRich Trott <rtrott@gmail.com>2018-11-27 22:19:35 -0800
commit3ce9305a705a0ea521a82afb0e4a2bef079d9548 (patch)
treed496b6b2cb95f2bf345817a8688fda0a15fa490c /test
parentb5c5d206af8fd32f33953d564a151a5a20bfb5b1 (diff)
downloadandroid-node-v8-3ce9305a705a0ea521a82afb0e4a2bef079d9548.tar.gz
android-node-v8-3ce9305a705a0ea521a82afb0e4a2bef079d9548.tar.bz2
android-node-v8-3ce9305a705a0ea521a82afb0e4a2bef079d9548.zip
process: emit unhandled warning immediately
PR-URL: https://github.com/nodejs/node/pull/24632 Fixes: https://github.com/nodejs/node/issues/24209 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-promises-unhandled-rejections.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/parallel/test-promises-unhandled-rejections.js b/test/parallel/test-promises-unhandled-rejections.js
index fdbf17b959..4464fad8e4 100644
--- a/test/parallel/test-promises-unhandled-rejections.js
+++ b/test/parallel/test-promises-unhandled-rejections.js
@@ -699,3 +699,22 @@ asyncTest('Rejected promise inside unhandledRejection allows nextTick loop' +
process.nextTick(() => promise.catch(() => done()));
});
});
+
+asyncTest(
+ 'Unhandled promise rejection emits a warning immediately',
+ function(done) {
+ clean();
+ Promise.reject(0);
+ const { emitWarning } = process;
+ process.emitWarning = common.mustCall((...args) => {
+ if (timer) {
+ clearTimeout(timer);
+ timer = null;
+ done();
+ }
+ emitWarning(...args);
+ }, 2);
+
+ let timer = setTimeout(common.mustNotCall(), 10000);
+ },
+);