Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: pass isMainThread into bootstrap/node.js directly #25017

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,7 +30,6 @@ const {
const { internalBinding, NativeModule } = loaderExports;

const exceptionHandlerState = { captureFn: null };
const isMainThread = internalBinding('worker').threadId === 0;

function startup() {
setupTraceCategoryState();
Expand Down
6 changes: 4 additions & 2 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1276,14 +1276,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<Local<Value>> 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)
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-bootstrap-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const common = require('../common');
const assert = require('assert');

const isMainThread = common.isMainThread;
const kMaxModuleCount = isMainThread ? 60 : 82;
const kMaxModuleCount = isMainThread ? 59 : 82;

assert(list.length <= kMaxModuleCount,
`Total length: ${list.length}\n` + list.join('\n')
Expand Down