mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix: Don't panic when a worker is closed in the reactions to a wasm operation. (#12270)
This commit is contained in:
parent
b1eeaf71ff
commit
c79fd8f419
5 changed files with 41 additions and 0 deletions
|
@ -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()
|
||||
|
|
10
cli/tests/testdata/worker_close_in_wasm_reactions.js
vendored
Normal file
10
cli/tests/testdata/worker_close_in_wasm_reactions.js
vendored
Normal file
|
@ -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" },
|
||||
);
|
1
cli/tests/testdata/worker_close_in_wasm_reactions.js.out
vendored
Normal file
1
cli/tests/testdata/worker_close_in_wasm_reactions.js.out
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Error: CompileError: WebAssembly.compile(): expected string length @+10
|
21
cli/tests/testdata/workers/close_in_wasm_reactions.js
vendored
Normal file
21
cli/tests/testdata/workers/close_in_wasm_reactions.js
vendored
Normal file
|
@ -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();
|
||||
});
|
|
@ -1549,6 +1549,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;
|
||||
|
|
Loading…
Reference in a new issue