diff options
Diffstat (limited to 'tests/unit_node/worker_threads_test.ts')
-rw-r--r-- | tests/unit_node/worker_threads_test.ts | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/unit_node/worker_threads_test.ts b/tests/unit_node/worker_threads_test.ts index 5d3023069..bc451e33f 100644 --- a/tests/unit_node/worker_threads_test.ts +++ b/tests/unit_node/worker_threads_test.ts @@ -1,6 +1,11 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { assert, assertEquals, assertObjectMatch } from "@std/assert/mod.ts"; +import { + assert, + assertEquals, + assertObjectMatch, + fail, +} from "@std/assert/mod.ts"; import { fromFileUrl, relative } from "@std/path/mod.ts"; import * as workerThreads from "node:worker_threads"; import { EventEmitter, once } from "node:events"; @@ -198,3 +203,18 @@ Deno.test({ worker.terminate(); }, }); + +Deno.test({ + name: "[worker_threads] unref", + async fn() { + const timeout = setTimeout(() => fail("Test timed out"), 60_000); + const child = new Deno.Command(Deno.execPath(), { + args: [ + "eval", + "import { Worker } from 'node:worker_threads'; new Worker('setTimeout(() => {}, 1_000_000)', {eval:true}).unref();", + ], + }).spawn(); + await child.status; + clearTimeout(timeout); + }, +}); |