summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2024-04-16 15:14:59 -0600
committerGitHub <noreply@github.com>2024-04-16 15:14:59 -0600
commit9c0446567bd8c6441e0ced61eeb4b0e5604ac21e (patch)
tree65354977f0ca301dcdaaa53b9d892c91112ea93a /tests
parentd01e4c43c814f42fc1c16037bc050bf697dcf60e (diff)
fix(cli): Identify and fix a test deadlock (#23411)
If a worker tried to flush large amounts of data right as the test was ending, it could cause the flush sync marker to get lost.
Diffstat (limited to 'tests')
-rw-r--r--tests/specs/test/worker_large_output/__test__.jsonc4
-rw-r--r--tests/specs/test/worker_large_output/main.js15
-rw-r--r--tests/specs/test/worker_large_output/main.out4
3 files changed, 23 insertions, 0 deletions
diff --git a/tests/specs/test/worker_large_output/__test__.jsonc b/tests/specs/test/worker_large_output/__test__.jsonc
new file mode 100644
index 000000000..9e6533e8c
--- /dev/null
+++ b/tests/specs/test/worker_large_output/__test__.jsonc
@@ -0,0 +1,4 @@
+{
+ "args": "test main.js",
+ "output": "main.out"
+}
diff --git a/tests/specs/test/worker_large_output/main.js b/tests/specs/test/worker_large_output/main.js
new file mode 100644
index 000000000..0941e60f3
--- /dev/null
+++ b/tests/specs/test/worker_large_output/main.js
@@ -0,0 +1,15 @@
+// Regression test for workers that post large amounts of output as a test is ending. This
+// test should not deadlock, though the output is undefined.
+Deno.test(async function workerOutput() {
+ console.log("Booting worker");
+ const code =
+ "self.postMessage(0); console.log(`hello from worker\n`.repeat(60000));";
+ const worker = new Worker(URL.createObjectURL(new Blob([code])), {
+ type: "module",
+ });
+ await new Promise((r) =>
+ worker.addEventListener("message", () => {
+ r();
+ })
+ );
+});
diff --git a/tests/specs/test/worker_large_output/main.out b/tests/specs/test/worker_large_output/main.out
new file mode 100644
index 000000000..ed130e0fe
--- /dev/null
+++ b/tests/specs/test/worker_large_output/main.out
@@ -0,0 +1,4 @@
+[WILDCARD]
+
+ok | 1 passed | 0 failed ([WILDCARD])
+