summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock12
-rw-r--r--Cargo.toml2
-rw-r--r--cli/tests/integration/compile_tests.rs4
-rw-r--r--cli/tests/integration/repl_tests.rs4
-rw-r--r--cli/tests/integration/run_tests.rs6
-rw-r--r--cli/tests/integration/watcher_tests.rs6
-rw-r--r--cli/tests/testdata/bench/no_check.out2
-rw-r--r--cli/tests/testdata/error_cause_recursive_aggregate.ts.out2
-rw-r--r--cli/tests/testdata/error_cause_recursive_tail.ts.out2
-rw-r--r--cli/tests/testdata/node/require_esm_error/main.out2
-rw-r--r--cli/tests/testdata/npm/cjs_require_esm_error/main.out2
-rw-r--r--cli/tests/testdata/npm/cjs_require_esm_mjs_error/main.out2
-rw-r--r--cli/tests/testdata/npm/cjs_this_in_exports/main.out2
-rw-r--r--cli/tests/testdata/run/059_fs_relative_path_perm.ts.out2
-rw-r--r--cli/tests/testdata/run/077_fetch_empty.ts.out2
-rw-r--r--cli/tests/testdata/run/082_prepare_stack_trace_throw.js.out2
-rw-r--r--cli/tests/testdata/run/aggregate_error.out2
-rw-r--r--cli/tests/testdata/run/complex_error.ts.out2
-rw-r--r--cli/tests/testdata/run/dom_exception_formatting.ts.out2
-rw-r--r--cli/tests/testdata/run/error_001.ts.out2
-rw-r--r--cli/tests/testdata/run/error_002.ts.out2
-rw-r--r--cli/tests/testdata/run/error_007_any.ts.out2
-rw-r--r--cli/tests/testdata/run/error_008_checkjs.js.out2
-rw-r--r--cli/tests/testdata/run/error_009_extensions_error.js.out2
-rw-r--r--cli/tests/testdata/run/error_018_hide_long_source_js.js.out2
-rw-r--r--cli/tests/testdata/run/error_019_stack_function.ts.out2
-rw-r--r--cli/tests/testdata/run/error_020_stack_constructor.ts.out2
-rw-r--r--cli/tests/testdata/run/error_021_stack_method.ts.out2
-rw-r--r--cli/tests/testdata/run/error_022_stack_custom_error.ts.out2
-rw-r--r--cli/tests/testdata/run/error_023_stack_async.ts.out2
-rw-r--r--cli/tests/testdata/run/error_024_stack_promise_all.ts.out2
-rw-r--r--cli/tests/testdata/run/error_025_tab_indent.out2
-rw-r--r--cli/tests/testdata/run/error_026_remote_import_error.ts.out2
-rw-r--r--cli/tests/testdata/run/error_cause.ts.out2
-rw-r--r--cli/tests/testdata/run/error_cause_recursive.ts.out2
-rw-r--r--cli/tests/testdata/run/error_name_non_string.js.out2
-rw-r--r--cli/tests/testdata/run/error_with_errors_prop.js.out2
-rw-r--r--cli/tests/testdata/run/extension_dynamic_import.ts.out10
-rw-r--r--cli/tests/testdata/run/import_data_url_error_stack.ts.out2
-rw-r--r--cli/tests/testdata/run/inline_js_source_map_2.js.out2
-rw-r--r--cli/tests/testdata/run/inline_js_source_map_2_with_inline_contents.js.out2
-rw-r--r--cli/tests/testdata/run/inline_js_source_map_with_contents_from_graph.js.out2
-rw-r--r--cli/tests/testdata/run/nested_error/main.ts.out2
-rw-r--r--cli/tests/testdata/run/node_env_var_allowlist.ts.out2
-rw-r--r--cli/tests/testdata/run/with_config/auto_discovery_log.out1
-rw-r--r--cli/tests/testdata/run/with_package_json/no_deno_json/noconfig.out1
-rw-r--r--cli/tests/testdata/run/with_package_json/npm_binary/main.out1
-rw-r--r--cli/tests/testdata/test/no_check.out4
-rw-r--r--cli/tests/testdata/test/uncaught_errors.out2
-rw-r--r--cli/tests/testdata/workers/close_nested_child.js1
-rw-r--r--cli/tests/testdata/workers/error_event.ts.out4
-rw-r--r--cli/tests/testdata/workers/test.ts5
-rw-r--r--cli/tests/testdata/workers/worker_error.ts.out2
-rw-r--r--cli/tests/testdata/workers/worker_nested_error.ts.out2
-rw-r--r--ext/web/02_event.js3
-rw-r--r--runtime/fmt_errors.rs30
-rw-r--r--runtime/js/99_main.js120
-rw-r--r--runtime/web_worker.rs1
-rw-r--r--runtime/worker.rs1
59 files changed, 105 insertions, 191 deletions
diff --git a/Cargo.lock b/Cargo.lock
index a476b9eba..5e0e2bb42 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1065,9 +1065,9 @@ dependencies = [
[[package]]
name = "deno_core"
-version = "0.234.0"
+version = "0.235.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94fe0979c3e6fe8fada5d4895ddd043fb8d5936e0f4c4b4e76fab403bf21ee22"
+checksum = "dd09a1db8195a505dcb50664a3d932f75be9acaeb84b8952da3cf0a0b8309916"
dependencies = [
"anyhow",
"bytes",
@@ -1493,9 +1493,9 @@ dependencies = [
[[package]]
name = "deno_ops"
-version = "0.110.0"
+version = "0.111.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dab9fca550a1241267e56a9a8185f6263964233f980233cf70d47e587b5f866f"
+checksum = "4bdb7fe6c12234bf3b7542ff6d16951f9573c946280d918e21c7a7262907b9a7"
dependencies = [
"proc-macro-rules",
"proc-macro2",
@@ -4638,9 +4638,9 @@ dependencies = [
[[package]]
name = "serde_v8"
-version = "0.143.0"
+version = "0.144.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "331359280930e186b14c0f931433b75ec174edb017fa390bab8716d8e36c29ee"
+checksum = "73f73d99493115f9f3a9377c8e167e542da223da7a6d13f51b78912eb12d48ef"
dependencies = [
"bytes",
"derive_more",
diff --git a/Cargo.toml b/Cargo.toml
index 07c56eee9..5fa2d5e9a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -40,7 +40,7 @@ repository = "https://github.com/denoland/deno"
[workspace.dependencies]
deno_ast = { version = "0.31.6", features = ["transpiling"] }
-deno_core = { version = "0.234.0" }
+deno_core = { version = "0.235.0" }
deno_runtime = { version = "0.135.0", path = "./runtime" }
napi_sym = { version = "0.57.0", path = "./cli/napi/sym" }
diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs
index 95d214429..9b757bf55 100644
--- a/cli/tests/integration/compile_tests.rs
+++ b/cli/tests/integration/compile_tests.rs
@@ -105,7 +105,7 @@ fn standalone_error() {
let stderr = output.stderr();
// On Windows, we cannot assert the file path (because '\').
// Instead we just check for relevant output.
- assert_contains!(stderr, "error: Uncaught Error: boom!");
+ assert_contains!(stderr, "error: Uncaught (in promise) Error: boom!");
assert_contains!(stderr, "throw new Error(\"boom!\");");
assert_contains!(stderr, "\n at boom (file://");
assert_contains!(stderr, "standalone_error.ts:2:9");
@@ -145,7 +145,7 @@ fn standalone_error_module_with_imports() {
let stderr = output.stderr();
// On Windows, we cannot assert the file path (because '\').
// Instead we just check for relevant output.
- assert_contains!(stderr, "error: Uncaught Error: boom!");
+ assert_contains!(stderr, "error: Uncaught (in promise) Error: boom!");
assert_contains!(stderr, "throw new Error(\"boom!\");");
assert_contains!(stderr, "\n at file://");
assert_contains!(stderr, "standalone_error_module_with_imports_2.ts:2:7");
diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs
index 6c208ac2c..0ad271426 100644
--- a/cli/tests/integration/repl_tests.rs
+++ b/cli/tests/integration/repl_tests.rs
@@ -825,7 +825,7 @@ fn repl_reject() {
console.write_line(r#"Promise.reject(new Error("foo"));"#);
console.expect("Promise {");
console.expect(" <rejected> Error: foo");
- console.expect("Uncaught (in promise) Error: foo");
+ console.expect("Uncaught Error: foo");
console.expect(" at <anonymous>");
console.write_line("console.log(2);");
console.expect("2");
@@ -857,7 +857,7 @@ fn repl_error_undefined() {
console.expect("Uncaught undefined");
console.write_line(r#"Promise.reject();"#);
console.expect("Promise { <rejected> undefined }");
- console.expect("Uncaught (in promise) undefined");
+ console.expect("Uncaught undefined");
console.write_line(r#"reportError(undefined);"#);
console.expect("undefined");
console.expect("Uncaught undefined");
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 2e950a0f8..b3bd98098 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -3926,7 +3926,7 @@ async fn test_resolve_dns() {
let out = String::from_utf8_lossy(&output.stdout);
assert!(!output.status.success());
assert!(err.starts_with("Check file"));
- assert!(err.contains(r#"error: Uncaught PermissionDenied: Requires net access to "127.0.0.1:4553""#));
+ assert!(err.contains(r#"error: Uncaught (in promise) PermissionDenied: Requires net access to "127.0.0.1:4553""#));
assert!(out.is_empty());
}
@@ -3947,7 +3947,7 @@ async fn test_resolve_dns() {
let out = String::from_utf8_lossy(&output.stdout);
assert!(!output.status.success());
assert!(err.starts_with("Check file"));
- assert!(err.contains(r#"error: Uncaught PermissionDenied: Requires net access to "127.0.0.1:4553""#));
+ assert!(err.contains(r#"error: Uncaught (in promise) PermissionDenied: Requires net access to "127.0.0.1:4553""#));
assert!(out.is_empty());
}
@@ -4067,7 +4067,7 @@ fn broken_stdout() {
assert!(!output.status.success());
let stderr = std::str::from_utf8(output.stderr.as_ref()).unwrap().trim();
- assert!(stderr.contains("Uncaught BrokenPipe"));
+ assert!(stderr.contains("Uncaught (in promise) BrokenPipe"));
assert!(!stderr.contains("panic"));
}
diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs
index a690db846..f90db6f49 100644
--- a/cli/tests/integration/watcher_tests.rs
+++ b/cli/tests/integration/watcher_tests.rs
@@ -967,7 +967,11 @@ async fn run_watch_error_messages() {
let (_, mut stderr_lines) = child_lines(&mut child);
wait_contains("Process started", &mut stderr_lines).await;
- wait_contains("error: Uncaught SyntaxError: outer", &mut stderr_lines).await;
+ wait_contains(
+ "error: Uncaught (in promise) SyntaxError: outer",
+ &mut stderr_lines,
+ )
+ .await;
wait_contains("Caused by: TypeError: inner", &mut stderr_lines).await;
wait_contains("Process failed", &mut stderr_lines).await;
diff --git a/cli/tests/testdata/bench/no_check.out b/cli/tests/testdata/bench/no_check.out
index 9548a4f3d..6dc016458 100644
--- a/cli/tests/testdata/bench/no_check.out
+++ b/cli/tests/testdata/bench/no_check.out
@@ -1,4 +1,4 @@
-error: TypeError: Cannot read properties of undefined (reading 'fn')
+error: (in promise) TypeError: Cannot read properties of undefined (reading 'fn')
Deno.bench();
^
at [WILDCARD]
diff --git a/cli/tests/testdata/error_cause_recursive_aggregate.ts.out b/cli/tests/testdata/error_cause_recursive_aggregate.ts.out
index 652403e4a..4ae20055a 100644
--- a/cli/tests/testdata/error_cause_recursive_aggregate.ts.out
+++ b/cli/tests/testdata/error_cause_recursive_aggregate.ts.out
@@ -1,4 +1,4 @@
-error: Uncaught AggregateError
+error: Uncaught (in promise) AggregateError
Error: bar <ref *1>
at file:///[WILDCARD]/error_cause_recursive_aggregate.ts:2:13
Caused by: Error: foo
diff --git a/cli/tests/testdata/error_cause_recursive_tail.ts.out b/cli/tests/testdata/error_cause_recursive_tail.ts.out
index e19fa39bc..04b15e91a 100644
--- a/cli/tests/testdata/error_cause_recursive_tail.ts.out
+++ b/cli/tests/testdata/error_cause_recursive_tail.ts.out
@@ -1,4 +1,4 @@
-error: Uncaught Error: baz
+error: Uncaught (in promise) Error: baz
const baz = new Error("baz", { cause: bar });
^
at file:///[WILDCARD]/error_cause_recursive_tail.ts:3:13
diff --git a/cli/tests/testdata/node/require_esm_error/main.out b/cli/tests/testdata/node/require_esm_error/main.out
index c7b355411..3db23ff24 100644
--- a/cli/tests/testdata/node/require_esm_error/main.out
+++ b/cli/tests/testdata/node/require_esm_error/main.out
@@ -1,3 +1,3 @@
-error: Uncaught Error: require() of ES Module [WILDCARD]esm.js from [WILDCARD]main.ts not supported. Instead change the require to a dynamic import() which is available in all CommonJS modules.
+error: Uncaught (in promise) Error: require() of ES Module [WILDCARD]esm.js from [WILDCARD]main.ts not supported. Instead change the require to a dynamic import() which is available in all CommonJS modules.
at [WILDCARD]
at file:///[WILDCARD]/require_esm_error/main.ts:5:1
diff --git a/cli/tests/testdata/npm/cjs_require_esm_error/main.out b/cli/tests/testdata/npm/cjs_require_esm_error/main.out
index 5c735b3a6..f24675de9 100644
--- a/cli/tests/testdata/npm/cjs_require_esm_error/main.out
+++ b/cli/tests/testdata/npm/cjs_require_esm_error/main.out
@@ -1,2 +1,2 @@
-error: Uncaught Error: require() of ES Module [WILDCARD]my_esm_module.js from [WILDCARD]index.js not supported. Instead change the require to a dynamic import() which is available in all CommonJS modules.
+error: Uncaught (in promise) Error: require() of ES Module [WILDCARD]my_esm_module.js from [WILDCARD]index.js not supported. Instead change the require to a dynamic import() which is available in all CommonJS modules.
[WILDCARD]
diff --git a/cli/tests/testdata/npm/cjs_require_esm_mjs_error/main.out b/cli/tests/testdata/npm/cjs_require_esm_mjs_error/main.out
index e6a8abe27..e779cfaf8 100644
--- a/cli/tests/testdata/npm/cjs_require_esm_mjs_error/main.out
+++ b/cli/tests/testdata/npm/cjs_require_esm_mjs_error/main.out
@@ -1,2 +1,2 @@
-error: Uncaught Error: require() of ES Module [WILDCARD]esm_mjs.mjs from [WILDCARD]require_mjs.js not supported. Instead change the require to a dynamic import() which is available in all CommonJS modules.
+error: Uncaught (in promise) Error: require() of ES Module [WILDCARD]esm_mjs.mjs from [WILDCARD]require_mjs.js not supported. Instead change the require to a dynamic import() which is available in all CommonJS modules.
[WILDCARD]
diff --git a/cli/tests/testdata/npm/cjs_this_in_exports/main.out b/cli/tests/testdata/npm/cjs_this_in_exports/main.out
index 653a62335..ba436bddc 100644
--- a/cli/tests/testdata/npm/cjs_this_in_exports/main.out
+++ b/cli/tests/testdata/npm/cjs_this_in_exports/main.out
@@ -1,5 +1,5 @@
1
1
-error: Uncaught TypeError: this.otherMethod is not a function
+error: Uncaught (in promise) TypeError: this.otherMethod is not a function
at getValue (file://[WILDCARD]/@denotest/cjs-this-in-exports/1.0.0/index.js:3:17)
at file://[WILDCARD]/testdata/npm/cjs_this_in_exports/main.js:11:1
diff --git a/cli/tests/testdata/run/059_fs_relative_path_perm.ts.out b/cli/tests/testdata/run/059_fs_relative_path_perm.ts.out
index b55412137..b23628cd6 100644
--- a/cli/tests/testdata/run/059_fs_relative_path_perm.ts.out
+++ b/cli/tests/testdata/run/059_fs_relative_path_perm.ts.out
@@ -1,4 +1,4 @@
-[WILDCARD]error: Uncaught PermissionDenied: Requires read access to "non-existent", run again with the --allow-read flag
+[WILDCARD]error: Uncaught (in promise) PermissionDenied: Requires read access to "non-existent", run again with the --allow-read flag
Deno.readFileSync("non-existent");
^
at [WILDCARD]
diff --git a/cli/tests/testdata/run/077_fetch_empty.ts.out b/cli/tests/testdata/run/077_fetch_empty.ts.out
index 797574350..f11e0f563 100644
--- a/cli/tests/testdata/run/077_fetch_empty.ts.out
+++ b/cli/tests/testdata/run/077_fetch_empty.ts.out
@@ -1,2 +1,2 @@
-[WILDCARD]error: Uncaught TypeError: Invalid URL: ''
+[WILDCARD]error: Uncaught (in promise) TypeError: Invalid URL: ''
[WILDCARD]
diff --git a/cli/tests/testdata/run/082_prepare_stack_trace_throw.js.out b/cli/tests/testdata/run/082_prepare_stack_trace_throw.js.out
index 751b7c971..b6715c749 100644
--- a/cli/tests/testdata/run/082_prepare_stack_trace_throw.js.out
+++ b/cli/tests/testdata/run/082_prepare_stack_trace_throw.js.out
@@ -1,2 +1,2 @@
-[WILDCARD]error: Uncaught Error: foo
+[WILDCARD]error: Uncaught (in promise) Error: foo
[WILDCARD]
diff --git a/cli/tests/testdata/run/aggregate_error.out b/cli/tests/testdata/run/aggregate_error.out
index 7d0c09c70..59c0fb2a5 100644
--- a/cli/tests/testdata/run/aggregate_error.out
+++ b/cli/tests/testdata/run/aggregate_error.out
@@ -8,7 +8,7 @@ AggregateError: Multiple errors.
at [WILDCARD]/aggregate_error.ts:3:3
at [WILDCARD]/aggregate_error.ts:1:24
-error: Uncaught AggregateError: Multiple errors.
+error: Uncaught (in promise) AggregateError: Multiple errors.
Error: Error message 1.
at [WILDCARD]/aggregate_error.ts:2:3
Error: Error message 2.
diff --git a/cli/tests/testdata/run/complex_error.ts.out b/cli/tests/testdata/run/complex_error.ts.out
index eef1b7699..3c3c26eaf 100644
--- a/cli/tests/testdata/run/complex_error.ts.out
+++ b/cli/tests/testdata/run/complex_error.ts.out
@@ -16,7 +16,7 @@ AggregateError: foo1
Caused by AggregateError: foo2
at [WILDCARD]/complex_error.ts:8:12
-error: Uncaught AggregateError: foo1
+error: Uncaught (in promise) AggregateError: foo1
AggregateError
Error: qux1
at [WILDCARD]/complex_error.ts:3:25
diff --git a/cli/tests/testdata/run/dom_exception_formatting.ts.out b/cli/tests/testdata/run/dom_exception_formatting.ts.out
index bcdd714ea..75615d0a8 100644
--- a/cli/tests/testdata/run/dom_exception_formatting.ts.out
+++ b/cli/tests/testdata/run/dom_exception_formatting.ts.out
@@ -1,3 +1,3 @@
-[WILDCARD]error: Uncaught SyntaxError: foo
+[WILDCARD]error: Uncaught (in promise) SyntaxError: foo
[WILDCARD]
at file:///[WILDCARD]/dom_exception_formatting.ts:[WILDCARD]
diff --git a/cli/tests/testdata/run/error_001.ts.out b/cli/tests/testdata/run/error_001.ts.out
index 25664a9a4..9d8559917 100644
--- a/cli/tests/testdata/run/error_001.ts.out
+++ b/cli/tests/testdata/run/error_001.ts.out
@@ -1,4 +1,4 @@
-[WILDCARD]error: Uncaught Error: bad
+[WILDCARD]error: Uncaught (in promise) Error: bad
throw Error("bad");
^
at foo ([WILDCARD]/error_001.ts:2:9)
diff --git a/cli/tests/testdata/run/error_002.ts.out b/cli/tests/testdata/run/error_002.ts.out
index 96b9e602a..9fec5d968 100644
--- a/cli/tests/testdata/run/error_002.ts.out
+++ b/cli/tests/testdata/run/error_002.ts.out
@@ -1,4 +1,4 @@
-[WILDCARD]error: Uncaught Error: exception from mod1
+[WILDCARD]error: Uncaught (in promise) Error: exception from mod1
throw Error("exception from mod1");
^
at throwsError ([WILDCARD]/subdir/mod1.ts:16:9)
diff --git a/cli/tests/testdata/run/error_007_any.ts.out b/cli/tests/testdata/run/error_007_any.ts.out
index b93ceb1d0..8d13dadb9 100644
--- a/cli/tests/testdata/run/error_007_any.ts.out
+++ b/cli/tests/testdata/run/error_007_any.ts.out
@@ -1 +1 @@
-[WILDCARD]error: Uncaught { foo: "bar" }
+[WILDCARD]error: Uncaught (in promise) { foo: "bar" }
diff --git a/cli/tests/testdata/run/error_008_checkjs.js.out b/cli/tests/testdata/run/error_008_checkjs.js.out
index e43187382..bab481422 100644
--- a/cli/tests/testdata/run/error_008_checkjs.js.out
+++ b/cli/tests/testdata/run/error_008_checkjs.js.out
@@ -1,4 +1,4 @@
-[WILDCARD]error: Uncaught ReferenceError: consol is not defined
+[WILDCARD]error: Uncaught (in promise) ReferenceError: consol is not defined
consol.log("hello world!");
^
at [WILDCARD]/error_008_checkjs.js:2:1
diff --git a/cli/tests/testdata/run/error_009_extensions_error.js.out b/cli/tests/testdata/run/error_009_extensions_error.js.out
index ec286a60a..0fd1306de 100644
--- a/cli/tests/testdata/run/error_009_extensions_error.js.out
+++ b/cli/tests/testdata/run/error_009_extensions_error.js.out
@@ -1,4 +1,4 @@
-[WILDCARD]error: Uncaught TypeError: Failed to construct 'Event': 1 argument required, but only 0 present.
+[WILDCARD]error: Uncaught (in promise) TypeError: Failed to construct 'Event': 1 argument required, but only 0 present.
new Event();
^
at [WILDCARD]
diff --git a/cli/tests/testdata/run/error_018_hide_long_source_js.js.out b/cli/tests/testdata/run/error_018_hide_long_source_js.js.out
index cc98669a7..0897a100c 100644
--- a/cli/tests/testdata/run/error_018_hide_long_source_js.js.out
+++ b/cli/tests/testdata/run/error_018_hide_long_source_js.js.out
@@ -1,2 +1,2 @@
-error: Uncaught TypeError: Cannot read properties of undefined (reading 'a')
+error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'a')
at file:///[WILDCARD]/error_018_hide_long_source_js.js:3:206
diff --git a/cli/tests/testdata/run/error_019_stack_function.ts.out b/cli/tests/testdata/run/error_019_stack_function.ts.out
index 03967d12b..edaff27c0 100644
--- a/cli/tests/testdata/run/error_019_stack_function.ts.out
+++ b/cli/tests/testdata/run/error_019_stack_function.ts.out
@@ -1,7 +1,7 @@
[WILDCARD]Error: function
at foo ([WILDCARD]/error_019_stack_function.ts:[WILDCARD])
at [WILDCARD]/error_019_stack_function.ts:[WILDCARD]
-error: Uncaught Error: function
+error: Uncaught (in promise) Error: function
throw new Error("function");
^
at foo ([WILDCARD]/error_019_stack_function.ts:[WILDCARD])
diff --git a/cli/tests/testdata/run/error_020_stack_constructor.ts.out b/cli/tests/testdata/run/error_020_stack_constructor.ts.out
index 01fdfb3c4..9e48b8f98 100644
--- a/cli/tests/testdata/run/error_020_stack_constructor.ts.out
+++ b/cli/tests/testdata/run/error_020_stack_constructor.ts.out
@@ -1,7 +1,7 @@
[WILDCARD]Error: constructor
at new A ([WILDCARD]/error_020_stack_constructor.ts:[WILDCARD])
at [WILDCARD]/error_020_stack_constructor.ts:[WILDCARD]
-error: Uncaught Error: constructor
+error: Uncaught (in promise) Error: constructor
throw new Error("constructor");
^
at new A ([WILDCARD]/error_020_stack_constructor.ts:[WILDCARD])
diff --git a/cli/tests/testdata/run/error_021_stack_method.ts.out b/cli/tests/testdata/run/error_021_stack_method.ts.out
index 999f0aaa0..9df9b1b7c 100644
--- a/cli/tests/testdata/run/error_021_stack_method.ts.out
+++ b/cli/tests/testdata/run/error_021_stack_method.ts.out
@@ -1,7 +1,7 @@
[WILDCARD]Error: method
at A.m ([WILDCARD]/error_021_stack_method.ts:[WILDCARD])
at [WILDCARD]/error_021_stack_method.ts:[WILDCARD]
-error: Uncaught Error: method
+error: Uncaught (in promise) Error: method
throw new Error("method");
^
at A.m ([WILDCARD]/error_021_stack_method.ts:[WILDCARD])
diff --git a/cli/tests/testdata/run/error_022_stack_custom_error.ts.out b/cli/tests/testdata/run/error_022_stack_custom_error.ts.out
index 78b0dcaea..73e033e52 100644
--- a/cli/tests/testdata/run/error_022_stack_custom_error.ts.out
+++ b/cli/tests/testdata/run/error_022_stack_custom_error.ts.out
@@ -1,6 +1,6 @@
[WILDCARD]CustomError: custom error
at [WILDCARD]/error_022_stack_custom_error.ts:[WILDCARD]
-error: Uncaught CustomError: custom error
+error: Uncaught (in promise) CustomError: custom error
const error = new CustomError();
^
at [WILDCARD]/error_022_stack_custom_error.ts:[WILDCARD]
diff --git a/cli/tests/testdata/run/error_023_stack_async.ts.out b/cli/tests/testdata/run/error_023_stack_async.ts.out
index 95f0eae64..2d122d986 100644
--- a/cli/tests/testdata/run/error_023_stack_async.ts.out
+++ b/cli/tests/testdata/run/error_023_stack_async.ts.out
@@ -2,7 +2,7 @@
at [WILDCARD]/error_023_stack_async.ts:[WILDCARD]
at async [WILDCARD]/error_023_stack_async.ts:[WILDCARD]
at async [WILDCARD]/error_023_stack_async.ts:[WILDCARD]
-error: Uncaught Error: async
+error: Uncaught (in promise) Error: async
throw new Error("async");
^
at [WILDCARD]/error_023_stack_async.ts:[WILDCARD]
diff --git a/cli/tests/testdata/run/error_024_stack_promise_all.ts.out b/cli/tests/testdata/run/error_024_stack_promise_all.ts.out
index 6cd88715c..c7d10a649 100644
--- a/cli/tests/testdata/run/error_024_stack_promise_all.ts.out
+++ b/cli/tests/testdata/run/error_024_stack_promise_all.ts.out
@@ -2,7 +2,7 @@
at [WILDCARD]/error_024_stack_promise_all.ts:[WILDCARD]
at async Promise.all (index 1)
at async [WILDCARD]/error_024_stack_promise_all.ts:[WILDCARD]
-error: Uncaught Error: Promise.all()
+error: Uncaught (in promise) Error: Promise.all()
throw new Error("Promise.all()");
^
at [WILDCARD]/error_024_stack_promise_all.ts:[WILDCARD]
diff --git a/cli/tests/testdata/run/error_025_tab_indent.out b/cli/tests/testdata/run/error_025_tab_indent.out
index f1466ce3f..edf525c90 100644
--- a/cli/tests/testdata/run/error_025_tab_indent.out
+++ b/cli/tests/testdata/run/error_025_tab_indent.out
@@ -1,4 +1,4 @@
-[WILDCARD]error: Uncaught Error: bad
+[WILDCARD]error: Uncaught (in promise) Error: bad
throw Error("bad");
^
at foo ([WILDCARD]/error_025_tab_indent:2:8)
diff --git a/cli/tests/testdata/run/error_026_remote_import_error.ts.out b/cli/tests/testdata/run/error_026_remote_import_error.ts.out
index cc88284af..f3f8c0068 100644
--- a/cli/tests/testdata/run/error_026_remote_import_error.ts.out
+++ b/cli/tests/testdata/run/error_026_remote_import_error.ts.out
@@ -1,5 +1,5 @@
[WILDCARD]
-error: Uncaught Error: bad
+error: Uncaught (in promise) Error: bad
throw Error("bad");
^
at foo (http://localhost:4545/run/error_001.ts:2:9)
diff --git a/cli/tests/testdata/run/error_cause.ts.out b/cli/tests/testdata/run/error_cause.ts.out
index 6a8555646..4dc439ac9 100644
--- a/cli/tests/testdata/run/error_cause.ts.out
+++ b/cli/tests/testdata/run/error_cause.ts.out
@@ -1,4 +1,4 @@
-error: Uncaught Error: foo
+error: Uncaught (in promise) Error: foo
throw new Error("foo", { cause: new Error("bar", { cause: "deno" as any }) });
^
at a (file:///[WILDCARD]/error_cause.ts:3:9)
diff --git a/cli/tests/testdata/run/error_cause_recursive.ts.out b/cli/tests/testdata/run/error_cause_recursive.ts.out
index 9c381a974..52d5a03a1 100644
--- a/cli/tests/testdata/run/error_cause_recursive.ts.out
+++ b/cli/tests/testdata/run/error_cause_recursive.ts.out
@@ -1,4 +1,4 @@
-error: Uncaught Error: bar <ref *1>
+error: Uncaught (in promise) Error: bar <ref *1>
const y = new Error("bar", { cause: x });
^
at file:///[WILDCARD]/error_cause_recursive.ts:2:11
diff --git a/cli/tests/testdata/run/error_name_non_string.js.out b/cli/tests/testdata/run/error_name_non_string.js.out
index a77f336e9..14fa56c62 100644
--- a/cli/tests/testdata/run/error_name_non_string.js.out
+++ b/cli/tests/testdata/run/error_name_non_string.js.out
@@ -1,4 +1,4 @@
-error: Uncaught Error
+error: Uncaught (in promise) Error
throw new ErrorNameNonString();
^
at file:///[WILDCARD]/error_name_non_string.js:[WILDCARD]
diff --git a/cli/tests/testdata/run/error_with_errors_prop.js.out b/cli/tests/testdata/run/error_with_errors_prop.js.out
index 946b5ad84..d958996af 100644
--- a/cli/tests/testdata/run/error_with_errors_prop.js.out
+++ b/cli/tests/testdata/run/error_with_errors_prop.js.out
@@ -11,7 +11,7 @@ Error: Error with errors prop.
]
}
-error: Uncaught Error: Error with errors prop.
+error: Uncaught (in promise) Error: Error with errors prop.
const error = new Error("Error with errors prop.");
^
at [WILDCARD]/error_with_errors_prop.js:1:15
diff --git a/cli/tests/testdata/run/extension_dynamic_import.ts.out b/cli/tests/testdata/run/extension_dynamic_import.ts.out
index 4414ad923..b22717d62 100644
--- a/cli/tests/testdata/run/extension_dynamic_import.ts.out
+++ b/cli/tests/testdata/run/extension_dynamic_import.ts.out
@@ -1,10 +1,4 @@
-error: Uncaught (in promise) TypeError: Unsupported scheme "ext" for module "ext:runtime/01_errors.js". Supported schemes: [
- "data",
- "blob",
- "file",
- "http",
- "https",
-]
+error: Uncaught (in promise) TypeError: Importing ext: modules is only allowed from ext: and node: modules. Tried to import ext:runtime/01_errors.js from [WILDCARD]/testdata/run/extension_dynamic_import.ts
await import("ext:runtime/01_errors.js");
^
- at async [WILDCARD]/extension_dynamic_import.ts:1:1
+ at async [WILDCARD]/run/extension_dynamic_import.ts:1:1
diff --git a/cli/tests/testdata/run/import_data_url_error_stack.ts.out b/cli/tests/testdata/run/import_data_url_error_stack.ts.out
index e79b52b30..83eed611d 100644
--- a/cli/tests/testdata/run/import_data_url_error_stack.ts.out
+++ b/cli/tests/testdata/run/import_data_url_error_stack.ts.out
@@ -1,4 +1,4 @@
-error: Uncaught Error: Hello 2
+error: Uncaught (in promise) Error: Hello 2
throw new Error(`Hello ${A.C}`);
^
at a (data:application/typescript;base64,ZW51bSBBIHsKICBBLAog......JHtBLkN9YCk7CiB9CiA=:8:10)
diff --git a/cli/tests/testdata/run/inline_js_source_map_2.js.out b/cli/tests/testdata/run/inline_js_source_map_2.js.out
index 72a531b0b..ba3053eba 100644
--- a/cli/tests/testdata/run/inline_js_source_map_2.js.out
+++ b/cli/tests/testdata/run/inline_js_source_map_2.js.out
@@ -1,2 +1,2 @@
-error: Uncaught Error: Hello world!
+error: Uncaught (in promise) Error: Hello world!
at http://localhost:4545/run/inline_js_source_map_2.ts:6:7
diff --git a/cli/tests/testdata/run/inline_js_source_map_2_with_inline_contents.js.out b/cli/tests/testdata/run/inline_js_source_map_2_with_inline_contents.js.out
index 72a531b0b..ba3053eba 100644
--- a/cli/tests/testdata/run/inline_js_source_map_2_with_inline_contents.js.out
+++ b/cli/tests/testdata/run/inline_js_source_map_2_with_inline_contents.js.out
@@ -1,2 +1,2 @@
-error: Uncaught Error: Hello world!
+error: Uncaught (in promise) Error: Hello world!
at http://localhost:4545/run/inline_js_source_map_2.ts:6:7
diff --git a/cli/tests/testdata/run/inline_js_source_map_with_contents_from_graph.js.out b/cli/tests/testdata/run/inline_js_source_map_with_contents_from_graph.js.out
index 9a5a26a68..d80a1c7bb 100644
--- a/cli/tests/testdata/run/inline_js_source_map_with_contents_from_graph.js.out
+++ b/cli/tests/testdata/run/inline_js_source_map_with_contents_from_graph.js.out
@@ -1,4 +1,4 @@
-error: Uncaught Error: Hello world!
+error: Uncaught (in promise) Error: Hello world!
// throw new Error("Hello world!" as string);
^
at http://localhost:4545/run/inline_js_source_map.ts:6:7
diff --git a/cli/tests/testdata/run/nested_error/main.ts.out b/cli/tests/testdata/run/nested_error/main.ts.out
index 47c818ac1..05780bc6a 100644
--- a/cli/tests/testdata/run/nested_error/main.ts.out
+++ b/cli/tests/testdata/run/nested_error/main.ts.out
@@ -1,4 +1,4 @@
-error: Uncaught {
+error: Uncaught (in promise) {
foo: Error
at file:///[WILDCARD]/main.ts:2:8
}
diff --git a/cli/tests/testdata/run/node_env_var_allowlist.ts.out b/cli/tests/testdata/run/node_env_var_allowlist.ts.out
index 62f335c0f..ea66a2965 100644
--- a/cli/tests/testdata/run/node_env_var_allowlist.ts.out
+++ b/cli/tests/testdata/run/node_env_var_allowlist.ts.out
@@ -1,5 +1,5 @@
ok
-[WILDCARD]error: Uncaught PermissionDenied: Requires env access to "NOT_NODE_DEBUG", run again with the --allow-env flag
+[WILDCARD]error: Uncaught (in promise) PermissionDenied: Requires env access to "NOT_NODE_DEBUG", run again with the --allow-env flag
Deno.env.get("NOT_NODE_DEBUG");
^
at [WILDCARD]
diff --git a/cli/tests/testdata/run/with_config/auto_discovery_log.out b/cli/tests/testdata/run/with_config/auto_discovery_log.out
index 601c1adc6..1a25eb9a7 100644
--- a/cli/tests/testdata/run/with_config/auto_discovery_log.out
+++ b/cli/tests/testdata/run/with_config/auto_discovery_log.out
@@ -1,3 +1,4 @@
DEBUG RS - [WILDCARD] - Config file found at '[WILDCARD]deno.jsonc'
[WILDCARD]
ok
+[WILDCARD]
diff --git a/cli/tests/testdata/run/with_package_json/no_deno_json/noconfig.out b/cli/tests/testdata/run/with_package_json/no_deno_json/noconfig.out
index ee6e346de..b9f9a6dea 100644
--- a/cli/tests/testdata/run/with_package_json/no_deno_json/noconfig.out
+++ b/cli/tests/testdata/run/with_package_json/no_deno_json/noconfig.out
@@ -1,3 +1,4 @@
[WILDCARD]package.json auto-discovery is disabled
[WILDCARD]
success
+[WILDCARD]
diff --git a/cli/tests/testdata/run/with_package_json/npm_binary/main.out b/cli/tests/testdata/run/with_package_json/npm_binary/main.out
index 56cdae6f9..13d196a5e 100644
--- a/cli/tests/testdata/run/with_package_json/npm_binary/main.out
+++ b/cli/tests/testdata/run/with_package_json/npm_binary/main.out
@@ -4,3 +4,4 @@ this
is
a
test
+[WILDCARD]
diff --git a/cli/tests/testdata/test/no_check.out b/cli/tests/testdata/test/no_check.out
index adef03aee..66ad07e26 100644
--- a/cli/tests/testdata/test/no_check.out
+++ b/cli/tests/testdata/test/no_check.out
@@ -3,10 +3,10 @@ Uncaught error from ./test/no_check.ts FAILED
ERRORS
./test/no_check.ts (uncaught error)
-error: TypeError: Cannot read properties of undefined (reading 'fn')
+error: (in promise) TypeError: Cannot read properties of undefined (reading 'fn')
Deno.test();
^
- at [WILDCARD]/test/no_check.ts:1:6
+ at [WILDCARD]
This error was not caught from a test and caused the test runner to fail on the referenced module.
It most likely originated from a dangling promise, event/timeout handler or top-level code.
diff --git a/cli/tests/testdata/test/uncaught_errors.out b/cli/tests/testdata/test/uncaught_errors.out
index 2eae72e21..a52f95d57 100644
--- a/cli/tests/testdata/test/uncaught_errors.out
+++ b/cli/tests/testdata/test/uncaught_errors.out
@@ -39,7 +39,7 @@ error: Error: bar 3 message
at [WILDCARD]/test/uncaught_errors_2.ts:7:9
./test/uncaught_errors_3.ts (uncaught error)
-error: Error: baz
+error: (in promise) Error: baz
throw new Error("baz");
^
at [WILDCARD]/test/uncaught_errors_3.ts:1:7
diff --git a/cli/tests/testdata/workers/close_nested_child.js b/cli/tests/testdata/workers/close_nested_child.js
index bd95ae08c..7c6ad603c 100644
--- a/cli/tests/testdata/workers/close_nested_child.js
+++ b/cli/tests/testdata/workers/close_nested_child.js
@@ -4,4 +4,5 @@ console.log("Starting the child worker");
setTimeout(() => {
console.log("The child worker survived the death of the parent!!!");
+ Deno.exit(1);
}, 2000);
diff --git a/cli/tests/testdata/workers/error_event.ts.out b/cli/tests/testdata/workers/error_event.ts.out
index 9c075e23e..833cca8be 100644
--- a/cli/tests/testdata/workers/error_event.ts.out
+++ b/cli/tests/testdata/workers/error_event.ts.out
@@ -1,10 +1,10 @@
-error: Uncaught (in worker "") Error: foo
+error: Uncaught (in worker "") (in promise) Error: foo
throw new Error("foo");
^
at foo ([WILDCARD]/error.ts:2:9)
at [WILDCARD]/error.ts:5:1
{
- message: "Uncaught Error: foo",
+ message: "Uncaught (in promise) Error: foo",
filename: "[WILDCARD]/error.ts",
lineno: 2,
colno: 9
diff --git a/cli/tests/testdata/workers/test.ts b/cli/tests/testdata/workers/test.ts
index 0f0a2e1c6..e052cf46b 100644
--- a/cli/tests/testdata/workers/test.ts
+++ b/cli/tests/testdata/workers/test.ts
@@ -94,7 +94,10 @@ Deno.test({
resolve(e.message);
};
- assertMatch(await promise as string, /Uncaught Error: Thrown error/);
+ assertMatch(
+ await promise as string,
+ /Uncaught \(in promise\) Error: Thrown error/,
+ );
throwingWorker.terminate();
},
});
diff --git a/cli/tests/testdata/workers/worker_error.ts.out b/cli/tests/testdata/workers/worker_error.ts.out
index 78d0c423e..1dd017770 100644
--- a/cli/tests/testdata/workers/worker_error.ts.out
+++ b/cli/tests/testdata/workers/worker_error.ts.out
@@ -1,4 +1,4 @@
-[WILDCARD]error: Uncaught (in worker "bar") Error: foo[WILDCARD]
+[WILDCARD]error: Uncaught (in worker "bar") (in promise) Error: foo[WILDCARD]
at foo ([WILDCARD])
at [WILDCARD]
error: Uncaught (in promise) Error: Unhandled error in child worker.
diff --git a/cli/tests/testdata/workers/worker_nested_error.ts.out b/cli/tests/testdata/workers/worker_nested_error.ts.out
index 15cb85b48..3622acfb3 100644
--- a/cli/tests/testdata/workers/worker_nested_error.ts.out
+++ b/cli/tests/testdata/workers/worker_nested_error.ts.out
@@ -1,4 +1,4 @@
-[WILDCARD]error: Uncaught (in worker "bar") Error: foo[WILDCARD]
+[WILDCARD]error: Uncaught (in worker "bar") (in promise) Error: foo[WILDCARD]
throw new Error("foo");
^
at foo ([WILDCARD]/workers/error.ts:[WILDCARD])
diff --git a/ext/web/02_event.js b/ext/web/02_event.js
index 3690f62b7..f0c24f353 100644
--- a/ext/web/02_event.js
+++ b/ext/web/02_event.js
@@ -6,7 +6,6 @@
// and impossible logic branches based on what Deno currently supports.
const core = globalThis.Deno.core;
-const ops = core.ops;
import * as webidl from "ext:deno_webidl/00_webidl.js";
import DOMException from "ext:deno_web/01_dom_exception.js";
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
@@ -1494,7 +1493,7 @@ function reportException(error) {
});
// Avoid recursing `reportException()` via error handlers more than once.
if (reportExceptionStackedCalls > 1 || globalThis_.dispatchEvent(event)) {
- ops.op_dispatch_exception(error);
+ core.reportUnhandledException(error);
}
reportExceptionStackedCalls--;
}
diff --git a/runtime/fmt_errors.rs b/runtime/fmt_errors.rs
index 5dcb96ec7..7945842bd 100644
--- a/runtime/fmt_errors.rs
+++ b/runtime/fmt_errors.rs
@@ -9,25 +9,6 @@ use deno_core::error::JsError;
use deno_core::error::JsStackFrame;
use std::fmt::Write as _;
-/// Compares all properties of JsError, except for JsError::cause.
-/// This function is used to detect that 2 JsError objects in a JsError::cause
-/// chain are identical, ie. there is a recursive cause.
-/// 01_console.js, which also detects recursive causes, can use JS object
-/// comparisons to compare errors. We don't have access to JS object identity in
-/// format_js_error().
-fn errors_are_equal_without_cause(a: &JsError, b: &JsError) -> bool {
- a.name == b.name
- && a.message == b.message
- && a.stack == b.stack
- // `a.cause == b.cause` omitted, because it is absent in recursive errors,
- // despite the error being identical to a previously seen one.
- && a.exception_message == b.exception_message
- && a.frames == b.frames
- && a.source_line == b.source_line
- && a.source_line_frame_index == b.source_line_frame_index
- && a.aggregated == b.aggregated
-}
-
#[derive(Debug, Clone)]
struct ErrorReference<'a> {
from: &'a JsError,
@@ -191,10 +172,7 @@ fn find_recursive_cause(js_error: &JsError) -> Option<ErrorReference> {
while let Some(cause) = &current_error.cause {
history.push(current_error);
- if let Some(seen) = history
- .iter()
- .find(|&el| errors_are_equal_without_cause(el, cause.as_ref()))
- {
+ if let Some(seen) = history.iter().find(|&el| cause.is_same_error(el)) {
return Some(ErrorReference {
from: current_error,
to: seen,
@@ -246,7 +224,7 @@ fn format_js_error_inner(
s.push_str(&js_error.exception_message);
if let Some(circular) = &circular {
- if errors_are_equal_without_cause(js_error, circular.reference.to) {
+ if js_error.is_same_error(circular.reference.to) {
write!(s, " {}", cyan(format!("<ref *{}>", circular.index))).unwrap();
}
}
@@ -281,9 +259,7 @@ fn format_js_error_inner(
if let Some(cause) = &js_error.cause {
let is_caused_by_circular = circular
.as_ref()
- .map(|circular| {
- errors_are_equal_without_cause(circular.reference.from, js_error)
- })
+ .map(|circular| js_error.is_same_error(circular.reference.from))
.unwrap_or(false);
let error_string = if is_caused_by_circular {
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index 6e43da085..050cd3bf8 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -9,12 +9,8 @@ const internals = globalThis.__bootstrap.internals;
const primordials = globalThis.__bootstrap.primordials;
const {
ArrayPrototypeFilter,
- ArrayPrototypeIndexOf,
ArrayPrototypeIncludes,
ArrayPrototypeMap,
- ArrayPrototypePush,
- ArrayPrototypeShift,
- ArrayPrototypeSplice,
DateNow,
Error,
ErrorPrototype,
@@ -27,13 +23,9 @@ const {
ObjectSetPrototypeOf,
PromisePrototypeThen,
PromiseResolve,
- SafeWeakMap,
Symbol,
SymbolIterator,
TypeError,
- WeakMapPrototypeDelete,
- WeakMapPrototypeGet,
- WeakMapPrototypeSet,
} = primordials;
import * as util from "ext:runtime/06_util.js";
import * as event from "ext:deno_web/02_event.js";
@@ -328,7 +320,6 @@ function runtimeStart(
target,
) {
core.setMacrotaskCallback(timers.handleTimerMacrotask);
- core.setMacrotaskCallback(promiseRejectMacrotaskCallback);
core.setWasmStreamingCallback(fetch.handleWasmStreaming);
core.setReportExceptionCallback(event.reportException);
ops.op_set_format_exception_callback(formatException);
@@ -340,91 +331,38 @@ function runtimeStart(
core.setBuildInfo(target);
}
-const pendingRejections = [];
-const pendingRejectionsReasons = new SafeWeakMap();
-
-function promiseRejectCallback(type, promise, reason) {
- switch (type) {
- case 0: {
- ops.op_store_pending_promise_rejection(promise, reason);
- ArrayPrototypePush(pendingRejections, promise);
- WeakMapPrototypeSet(pendingRejectionsReasons, promise, reason);
- break;
- }
- case 1: {
- ops.op_remove_pending_promise_rejection(promise);
- const index = ArrayPrototypeIndexOf(pendingRejections, promise);
- if (index > -1) {
- ArrayPrototypeSplice(pendingRejections, index, 1);
- WeakMapPrototypeDelete(pendingRejectionsReasons, promise);
- }
- break;
- }
- default:
- return false;
- }
-
- return !!globalThis_.onunhandledrejection ||
- event.listenerCount(globalThis_, "unhandledrejection") > 0 ||
- typeof internals.nodeProcessUnhandledRejectionCallback !== "undefined";
-}
-
-function promiseRejectMacrotaskCallback() {
- // We have no work to do, tell the runtime that we don't
- // need to perform microtask checkpoint.
- if (pendingRejections.length === 0) {
- return undefined;
- }
-
- while (pendingRejections.length > 0) {
- const promise = ArrayPrototypeShift(pendingRejections);
- const hasPendingException = ops.op_has_pending_promise_rejection(
+core.setUnhandledPromiseRejectionHandler(processUnhandledPromiseRejection);
+// Notification that the core received an unhandled promise rejection that is about to
+// terminate the runtime. If we can handle it, attempt to do so.
+function processUnhandledPromiseRejection(promise, reason) {
+ const rejectionEvent = new event.PromiseRejectionEvent(
+ "unhandledrejection",
+ {
+ cancelable: true,
promise,
- );
- const reason = WeakMapPrototypeGet(pendingRejectionsReasons, promise);
- WeakMapPrototypeDelete(pendingRejectionsReasons, promise);
+ reason,
+ },
+ );
- if (!hasPendingException) {
- continue;
- }
+ // Note that the handler may throw, causing a recursive "error" event
+ globalThis_.dispatchEvent(rejectionEvent);
- const rejectionEvent = new event.PromiseRejectionEvent(
- "unhandledrejection",
- {
- cancelable: true,
- promise,
- reason,
- },
- );
-
- const errorEventCb = (event) => {
- if (event.error === reason) {
- ops.op_remove_pending_promise_rejection(promise);
- }
- };
- // Add a callback for "error" event - it will be dispatched
- // if error is thrown during dispatch of "unhandledrejection"
- // event.
- globalThis_.addEventListener("error", errorEventCb);
- globalThis_.dispatchEvent(rejectionEvent);
- globalThis_.removeEventListener("error", errorEventCb);
-
- // If event was not yet prevented, try handing it off to Node compat layer
- // (if it was initialized)
- if (
- !rejectionEvent.defaultPrevented &&
- typeof internals.nodeProcessUnhandledRejectionCallback !== "undefined"
- ) {
- internals.nodeProcessUnhandledRejectionCallback(rejectionEvent);
- }
+ // If event was not yet prevented, try handing it off to Node compat layer
+ // (if it was initialized)
+ if (
+ !rejectionEvent.defaultPrevented &&
+ typeof internals.nodeProcessUnhandledRejectionCallback !== "undefined"
+ ) {
+ internals.nodeProcessUnhandledRejectionCallback(rejectionEvent);
+ }
- // If event was not prevented (or "unhandledrejection" listeners didn't
- // throw) we will let Rust side handle it.
- if (rejectionEvent.defaultPrevented) {
- ops.op_remove_pending_promise_rejection(promise);
- }
+ // If event was not prevented (or "unhandledrejection" listeners didn't
+ // throw) we will let Rust side handle it.
+ if (rejectionEvent.defaultPrevented) {
+ return true;
}
- return true;
+
+ return false;
}
let hasBootstrapped = false;
@@ -523,8 +461,6 @@ function bootstrapMainRuntime(runtimeOptions) {
event.defineEventHandler(globalThis, "unload");
event.defineEventHandler(globalThis, "unhandledrejection");
- core.setPromiseRejectCallback(promiseRejectCallback);
-
runtimeStart(
denoVersion,
v8Version,
@@ -642,8 +578,6 @@ function bootstrapWorkerRuntime(
event.defineEventHandler(self, "error", undefined, true);
event.defineEventHandler(self, "unhandledrejection");
- core.setPromiseRejectCallback(promiseRejectCallback);
-
// `Deno.exit()` is an alias to `self.close()`. Setting and exit
// code using an op in worker context is a no-op.
os.setExitHandler((_exitCode) => {
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs
index e5adf4cc6..5b8c1944a 100644
--- a/runtime/web_worker.rs
+++ b/runtime/web_worker.rs
@@ -182,6 +182,7 @@ impl WebWorkerInternalHandle {
/// This function will set terminated to true, terminate the isolate and close the message channel
pub fn terminate(&mut self) {
self.cancel.cancel();
+ self.terminate_waker.wake();
// This function can be called multiple times by whomever holds
// the handle. However only a single "termination" should occur so
diff --git a/runtime/worker.rs b/runtime/worker.rs
index e3e97de7e..3267bd78d 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -1,5 +1,4 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-
use std::rc::Rc;
use std::sync::atomic::AtomicI32;
use std::sync::atomic::Ordering::Relaxed;