summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/worker_close_nested.js
diff options
context:
space:
mode:
authorAndreu Botella <abb@randomunok.com>2021-09-25 04:26:57 +0200
committerGitHub <noreply@github.com>2021-09-24 19:26:57 -0700
commit1a6249c9717288e37873b692abac831f11c30f4e (patch)
treee8962a090909ac3187237319732ffb41b8a61a38 /cli/tests/testdata/worker_close_nested.js
parent4e2b59f9df5085025f08faea24e76b009e47f68d (diff)
chore(workers): Test that closing a worker closes any child workers (#12215)
Before #12156, closing a worker which had children would cause a panic (https://github.com/denoland/deno/issues/11342#issuecomment-918327693). After that PR, closing a worker will also close any child workers.
Diffstat (limited to 'cli/tests/testdata/worker_close_nested.js')
-rw-r--r--cli/tests/testdata/worker_close_nested.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/cli/tests/testdata/worker_close_nested.js b/cli/tests/testdata/worker_close_nested.js
new file mode 100644
index 000000000..fd47a5ae4
--- /dev/null
+++ b/cli/tests/testdata/worker_close_nested.js
@@ -0,0 +1,20 @@
+// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
+
+// Test that closing a worker which has living child workers will automatically
+// close the children.
+
+console.log("Starting the main thread");
+
+const worker = new Worker(
+ new URL("./workers/close_nested_parent.js", import.meta.url),
+ { type: "module" },
+);
+
+setTimeout(() => {
+ console.log("About to close");
+ worker.postMessage({});
+
+ // Keep the process running for another two seconds, to make sure there's no
+ // output from the child worker.
+ setTimeout(() => {}, 2000);
+}, 1000);