summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/02_init.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-03-08 16:31:11 +0000
committerGitHub <noreply@github.com>2024-03-08 17:31:11 +0100
commit93b9d114a4c87402fa82c3f59d6509179f1fd126 (patch)
treea64492d0aae2d7bb6808ef6d57e1b454297e52ff /ext/node/polyfills/02_init.js
parentd5b01e41586c05d2af0bcf361ed4eadd03d60765 (diff)
refactor(ext/node): worker_threads.isMainThread setup (#22785)
This commit changes how we figure out if we're running on main thread in `node:worker_threads` module. Instead of relying on quirky "magic variable" for a name to check if we're on main thread, we are now explicitly passing this information during bootstrapping of the runtime. As a side effect, `WorkerOptions.name` is more useful and matches what Node.js does more closely (though not fully). Towards https://github.com/denoland/deno/issues/22783
Diffstat (limited to 'ext/node/polyfills/02_init.js')
-rw-r--r--ext/node/polyfills/02_init.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/node/polyfills/02_init.js b/ext/node/polyfills/02_init.js
index 7d433fe0c..84f8a7cdc 100644
--- a/ext/node/polyfills/02_init.js
+++ b/ext/node/polyfills/02_init.js
@@ -13,6 +13,7 @@ let initialized = false;
function initialize(
usesLocalNodeModulesDir,
argv0,
+ runningOnMainThread,
) {
if (initialized) {
throw Error("Node runtime already initialized");
@@ -37,7 +38,7 @@ function initialize(
// FIXME(bartlomieju): not nice to depend on `Deno` namespace here
// but it's the only way to get `args` and `version` and this point.
internals.__bootstrapNodeProcess(argv0, Deno.args, Deno.version);
- internals.__initWorkerThreads();
+ internals.__initWorkerThreads(runningOnMainThread);
internals.__setupChildProcessIpcChannel();
// `Deno[Deno.internal].requireImpl` will be unreachable after this line.
delete internals.requireImpl;