Open scarf005 opened 10 months ago
test runners do not wait for web workers to terminate.
// a.ts setTimeout(() => console.log("hello"), 1000)
// a_test.ts const foo = () => { const worker = new Worker(new URL("./a.ts", import.meta.url), { type: "module" }) return new Promise(() => worker.terminate()) } Deno.test("wait for worker", async () => { console.log("begin") await foo() console.log("end") })
running 1 test from ./a_test.ts wait for worser ... ------- output ------- begin Check file:///home/scarf/repo/w1-social-feed/a.ts ok | 0 passed | 0 failed (110ms) error: Promise resolution is still pending but the event loop has already resolved.
deno 1.37.2+8f065a6 (canary, x86_64-unknown-linux-gnu) v8 11.8.172.13 typescript 5.2.2 Ubuntu 23.04
Hello @scarf005, FYI, workaround exists, don't await p, but await pWrapper(p, timeout)
await p
await pWrapper(p, timeout)
Summary
test runners do not wait for web workers to terminate.
Minimal reproduction
Actual behavior
System Info