summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/integration/run_tests.rs5
-rw-r--r--cli/tests/testdata/worker_close_in_wasm_reactions.js10
-rw-r--r--cli/tests/testdata/worker_close_in_wasm_reactions.js.out1
-rw-r--r--cli/tests/testdata/workers/close_in_wasm_reactions.js21
-rw-r--r--core/runtime.rs4
5 files changed, 41 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 8c196d6e3..8c337b771 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -1204,6 +1204,11 @@ itest!(worker_message_before_close {
output: "worker_message_before_close.js.out",
});
+itest!(worker_close_in_wasm_reactions {
+ args: "run --quiet --reload --allow-read worker_close_in_wasm_reactions.js",
+ output: "worker_close_in_wasm_reactions.js.out",
+});
+
#[test]
fn no_validate_asm() {
let output = util::deno_cmd()
diff --git a/cli/tests/testdata/worker_close_in_wasm_reactions.js b/cli/tests/testdata/worker_close_in_wasm_reactions.js
new file mode 100644
index 000000000..2f5ea32d5
--- /dev/null
+++ b/cli/tests/testdata/worker_close_in_wasm_reactions.js
@@ -0,0 +1,10 @@
+// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
+
+// https://github.com/denoland/deno/issues/12263
+// Test for a panic that happens when a worker is closed in the reactions of a
+// WASM async operation.
+
+new Worker(
+ new URL("./workers/close_in_wasm_reactions.js", import.meta.url),
+ { type: "module" },
+);
diff --git a/cli/tests/testdata/worker_close_in_wasm_reactions.js.out b/cli/tests/testdata/worker_close_in_wasm_reactions.js.out
new file mode 100644
index 000000000..eef017a96
--- /dev/null
+++ b/cli/tests/testdata/worker_close_in_wasm_reactions.js.out
@@ -0,0 +1 @@
+Error: CompileError: WebAssembly.compile(): expected string length @+10
diff --git a/cli/tests/testdata/workers/close_in_wasm_reactions.js b/cli/tests/testdata/workers/close_in_wasm_reactions.js
new file mode 100644
index 000000000..abe573108
--- /dev/null
+++ b/cli/tests/testdata/workers/close_in_wasm_reactions.js
@@ -0,0 +1,21 @@
+// https://github.com/denoland/deno/issues/12263
+// Test for a panic that happens when a worker is closed in the reactions of a
+// WASM async operation.
+
+// The minimum valid wasm module, plus two additional zero bytes.
+const buffer = new Uint8Array([
+ 0x00,
+ 0x61,
+ 0x73,
+ 0x6D,
+ 0x01,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+]);
+WebAssembly.compile(buffer).catch((err) => {
+ console.log("Error:", err);
+ self.close();
+});
diff --git a/core/runtime.rs b/core/runtime.rs
index 9a60a65ed..ffd8e49c5 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -1572,6 +1572,10 @@ impl JsRuntime {
return exception_to_err_result(tc_scope, exception, false);
}
+ if tc_scope.has_terminated() || tc_scope.is_execution_terminating() {
+ break;
+ }
+
let is_done = is_done.unwrap();
if is_done.is_true() {
break;