diff options
Diffstat (limited to 'ext/node/polyfills/worker_threads.ts')
| -rw-r--r-- | ext/node/polyfills/worker_threads.ts | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/ext/node/polyfills/worker_threads.ts b/ext/node/polyfills/worker_threads.ts index 4563f157f..49f2f3e3e 100644 --- a/ext/node/polyfills/worker_threads.ts +++ b/ext/node/polyfills/worker_threads.ts @@ -134,7 +134,6 @@ function toFileUrl(path: string): URL { : toFileUrlPosix(path); } -let threads = 0; const privateWorkerRef = Symbol("privateWorkerRef"); class NodeWorker extends EventEmitter { #id = 0; @@ -195,12 +194,10 @@ class NodeWorker extends EventEmitter { name = "[worker eval]"; } this.#name = name; - this.threadId = ++threads; const serializedWorkerMetadata = serializeJsMessageData({ workerData: options?.workerData, environmentData: environmentData, - threadId: this.threadId, }, options?.transferList ?? []); const id = op_create_worker( { @@ -216,6 +213,7 @@ class NodeWorker extends EventEmitter { serializedWorkerMetadata, ); this.#id = id; + this.threadId = id; this.#pollControl(); this.#pollMessages(); // https://nodejs.org/api/worker_threads.html#event-online @@ -391,6 +389,7 @@ let parentPort: ParentPort = null as any; internals.__initWorkerThreads = ( runningOnMainThread: boolean, + workerId, maybeWorkerMetadata, ) => { isMainThread = runningOnMainThread; @@ -414,11 +413,11 @@ internals.__initWorkerThreads = ( >(); parentPort = self as ParentPort; + threadId = workerId; if (maybeWorkerMetadata) { const { 0: metadata, 1: _ } = maybeWorkerMetadata; workerData = metadata.workerData; environmentData = metadata.environmentData; - threadId = metadata.threadId; } defaultExport.workerData = workerData; defaultExport.parentPort = parentPort; |
