From 93b9d114a4c87402fa82c3f59d6509179f1fd126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 8 Mar 2024 16:31:11 +0000 Subject: 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 --- runtime/js/99_main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 2299b63f9..82e444dfd 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -774,7 +774,7 @@ function bootstrapMainRuntime(runtimeOptions) { ObjectDefineProperty(globalThis, "Deno", core.propReadOnly(finalDenoNs)); if (nodeBootstrap) { - nodeBootstrap(hasNodeModulesDir, argv0); + nodeBootstrap(hasNodeModulesDir, argv0, /* runningOnMainThread */ true); } if (future) { @@ -909,7 +909,7 @@ function bootstrapWorkerRuntime( ObjectDefineProperty(globalThis, "Deno", core.propReadOnly(finalDenoNs)); if (nodeBootstrap) { - nodeBootstrap(hasNodeModulesDir, argv0); + nodeBootstrap(hasNodeModulesDir, argv0, /* runningOnMainThread */ false); } } -- cgit v1.2.3