diff --git a/lib/internal/modules/esm/hooks.js b/lib/internal/modules/esm/hooks.js index 05dfed0b7793b2..7add585f33192f 100644 --- a/lib/internal/modules/esm/hooks.js +++ b/lib/internal/modules/esm/hooks.js @@ -494,7 +494,7 @@ class HooksProxy { */ #lock; /** - * The InternalWorker instance, which lets us communicate with the loader thread. + * The HooksWorker instance, which lets us communicate with the loader thread. */ #worker; @@ -518,7 +518,7 @@ class HooksProxy { #isWorkerOwner = false; constructor() { - const { InternalWorker, hooksPort } = require('internal/worker'); + const { HooksWorker, hooksPort } = require('internal/worker'); const lock = new SharedArrayBuffer(SHARED_MEMORY_BYTE_LENGTH); this.#lock = new Int32Array(lock); @@ -527,7 +527,7 @@ class HooksProxy { // the existing instance. If another thread created it, the constructor will throw // Fallback is to use the existing hooksPort created by the thread that originally // spawned the customization hooks thread. - this.#worker = new InternalWorker(loaderWorkerId, { + this.#worker = new HooksWorker(loaderWorkerId, { stderr: false, stdin: false, stdout: false, @@ -551,10 +551,10 @@ class HooksProxy { waitForWorker() { // There is one Hooks instance for each worker thread. But only one of - // these Hooks instances has an InternalWorker. That was the Hooks instance + // these Hooks instances has a HooksWorker. That was the Hooks instance // created for the first thread that registers a hook set. // It means for all Hooks instances that are not on that thread => they are - // done because they delegate to the single InternalWorker. + // done because they delegate to the single HooksWorker. if (!this.#isWorkerOwner) { return; } diff --git a/lib/internal/worker.js b/lib/internal/worker.js index edb816797ab7bc..66cd0816096f2b 100644 --- a/lib/internal/worker.js +++ b/lib/internal/worker.js @@ -482,10 +482,10 @@ class Worker extends EventEmitter { } /** - * A worker which has an internal module for entry point (e.g. internal/module/esm/worker). - * Internal workers bypass the permission model. + * A worker which is used to by the customization hooks thread (internal/module/esm/worker). + * This bypasses the permission model. */ -class InternalWorker extends Worker { +class HooksWorker extends Worker { constructor(filename, options) { super(filename, options, kIsInternal); } @@ -570,6 +570,6 @@ module.exports = { getEnvironmentData, assignEnvironmentData, threadId, - InternalWorker, + HooksWorker, Worker, }; diff --git a/src/node_worker.cc b/src/node_worker.cc index 87107867b791e0..9c383802ed1ac6 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -46,7 +46,7 @@ namespace node { namespace worker { constexpr double kMB = 1024 * 1024; -std::atomic_bool Worker::internalExists{false}; +std::atomic_bool Worker::hooksWorkerExists{false}; Mutex Worker::instantiationMutex; Worker::Worker(Environment* env, @@ -498,14 +498,14 @@ void Worker::New(const FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); auto creatingHooksThread = is_internal->IsTrue(); - if (creatingHooksThread && internalExists) { + if (creatingHooksThread && hooksWorkerExists) { isolate->ThrowException(ERR_HOOKS_THREAD_EXISTS( isolate, "Customization hooks thread already exists")); return; } if (creatingHooksThread) { - internalExists = true; + hooksWorkerExists = true; } if (env->isolate_data()->platform() == nullptr) { @@ -918,7 +918,7 @@ void Worker::LoopStartTime(const FunctionCallbackInfo& args) { } void Worker::HasHooksThread(const FunctionCallbackInfo& args) { - args.GetReturnValue().Set(Worker::internalExists); + args.GetReturnValue().Set(Worker::hooksWorkerExists); } namespace { diff --git a/src/node_worker.h b/src/node_worker.h index 51cefa42972411..e56cffa8808b1d 100644 --- a/src/node_worker.h +++ b/src/node_worker.h @@ -104,7 +104,7 @@ class Worker : public AsyncWrap { uintptr_t stack_base_ = 0; // Optional name used for debugging in inspector and trace events. std::string name_; - static std::atomic_bool internalExists; + static std::atomic_bool hooksWorkerExists; // this mutex is to synchronize ::New calls static Mutex instantiationMutex;