From 0bb5bbc7a0ff7565a4c7fa4ebc8c69e02f76e6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 24 May 2023 15:40:41 +0200 Subject: fix(node): fire 'unhandledrejection' event when using node: or npm: imports (#19235) This commit fixes emitting "unhandledrejection" event when there are "node:" or "npm:" imports. Before this commit the Node "unhandledRejection" event was emitted using a regular listener for Web "unhandledrejection" event. This listener was installed before any user listener had a chance to be installed which effectively prevent emitting "unhandledrejection" events to user code. Closes https://github.com/denoland/deno/issues/16928 --- cli/tests/integration/node_unit_tests.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cli/tests/integration') diff --git a/cli/tests/integration/node_unit_tests.rs b/cli/tests/integration/node_unit_tests.rs index 2cde51552..7c524eb8b 100644 --- a/cli/tests/integration/node_unit_tests.rs +++ b/cli/tests/integration/node_unit_tests.rs @@ -5,6 +5,7 @@ use std::process::Stdio; use std::time::Duration; use std::time::Instant; use test_util as util; +use util::env_vars_for_npm_tests; util::unit_test_factory!( node_unit_test, @@ -157,3 +158,20 @@ fn node_unit_test(test: String) { assert!(status.success()); } + +// Regression test for https://github.com/denoland/deno/issues/16928 +itest!(unhandled_rejection_web { + args: "run -A node/unhandled_rejection_web.ts", + output: "node/unhandled_rejection_web.ts.out", + envs: env_vars_for_npm_tests(), + http_server: true, +}); + +// Ensure that Web `onunhandledrejection` is fired before +// Node's `process.on('unhandledRejection')`. +itest!(unhandled_rejection_web_process { + args: "run -A node/unhandled_rejection_web_process.ts", + output: "node/unhandled_rejection_web_process.ts.out", + envs: env_vars_for_npm_tests(), + http_server: true, +}); -- cgit v1.2.3