diff options
author | Satya Rohith <me@satyarohith.com> | 2024-03-13 22:52:25 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-13 17:22:25 +0000 |
commit | 0fd8f549e2194223eca2d4b17f4e96cd5a0f5fd5 (patch) | |
tree | 76181b2a5f2991134f7343cfc6d4b8b755dbc333 /tests/testdata/workers/node_worker_auto_exits.mjs | |
parent | b3ca3b2f25931afb350027bde87dc3d4f9a741b0 (diff) |
fix(ext/node): allow automatic worker_thread termination (#22647)
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
Diffstat (limited to 'tests/testdata/workers/node_worker_auto_exits.mjs')
-rw-r--r-- | tests/testdata/workers/node_worker_auto_exits.mjs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/testdata/workers/node_worker_auto_exits.mjs b/tests/testdata/workers/node_worker_auto_exits.mjs new file mode 100644 index 000000000..abfb084c3 --- /dev/null +++ b/tests/testdata/workers/node_worker_auto_exits.mjs @@ -0,0 +1,9 @@ +import { isMainThread, Worker } from "node:worker_threads"; + +if (isMainThread) { + // This re-loads the current file inside a Worker instance. + const w = new Worker(import.meta.filename); +} else { + console.log("Inside Worker!"); + console.log(isMainThread); // Prints 'false'. +} |