diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 29d4178dece48a..49a82d5137b490 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -15,6 +15,8 @@ // This file is compiled as if it's wrapped in a function with arguments // passed by node::LoadEnvironment() /* global process, bootstrappers, loaderExports, triggerFatalException */ +/* global isMainThread */ + const { _setupTraceCategoryState, _setupNextTick, @@ -28,7 +30,6 @@ const { const { internalBinding, NativeModule } = loaderExports; const exceptionHandlerState = { captureFn: null }; -const isMainThread = internalBinding('worker').threadId === 0; function startup() { setupTraceCategoryState(); diff --git a/src/node.cc b/src/node.cc index 2d84ccf5ae8c85..6b6ede3fdeae48 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1267,14 +1267,16 @@ void LoadEnvironment(Environment* env) { env->process_string(), FIXED_ONE_BYTE_STRING(isolate, "bootstrappers"), FIXED_ONE_BYTE_STRING(isolate, "loaderExports"), - FIXED_ONE_BYTE_STRING(isolate, "triggerFatalException")}; + FIXED_ONE_BYTE_STRING(isolate, "triggerFatalException"), + FIXED_ONE_BYTE_STRING(isolate, "isMainThread")}; std::vector> node_args = { process, bootstrapper, loader_exports.ToLocalChecked(), env->NewFunctionTemplate(FatalException) ->GetFunction(context) - .ToLocalChecked()}; + .ToLocalChecked(), + Boolean::New(isolate, env->is_main_thread())}; if (ExecuteBootstrapper( env, "internal/bootstrap/node", &node_params, &node_args) diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js index 9816aa05466ff3..5c1693ca89c5db 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -9,7 +9,7 @@ const common = require('../common'); const assert = require('assert'); const isMainThread = common.isMainThread; -const kMaxModuleCount = isMainThread ? 61 : 82; +const kMaxModuleCount = isMainThread ? 60 : 82; assert(list.length <= kMaxModuleCount, `Total length: ${list.length}\n` + list.join('\n')