From dd67c6792b3332a528cf6ba12c6762641f31e278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=9C=A3=E5=B3=B0?= Date: Thu, 14 Sep 2023 19:03:41 +0800 Subject: [PATCH 1/4] chore: modify worker file path to satisfy the dependency analysis --- src/runtime/thread-worker.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/runtime/thread-worker.ts b/src/runtime/thread-worker.ts index 0a8792e..ce4c3a8 100644 --- a/src/runtime/thread-worker.ts +++ b/src/runtime/thread-worker.ts @@ -1,5 +1,4 @@ import { fileURLToPath } from 'url' -import { dirname, resolve } from 'path' import { TransferListItem, Worker } from 'worker_threads' import { TinypoolWorker } from '../common' @@ -10,9 +9,7 @@ export default class ThreadWorker implements TinypoolWorker { threadId!: number initialize(options: Parameters[0]) { - const __dirname = dirname(fileURLToPath(import.meta.url)) - - this.thread = new Worker(resolve(__dirname, './entry/worker.js'), options) + this.thread = new Worker(fileURLToPath(import.meta.url + '/../entry/worker.js'), options); this.threadId = this.thread.threadId } From 9841d18cb70badc56ad0a412b68b7e3e142bf574 Mon Sep 17 00:00:00 2001 From: wujin Date: Fri, 15 Sep 2023 00:00:27 +0800 Subject: [PATCH 2/4] chore: also rewrite process file path --- src/runtime/process-worker.ts | 9 +++++---- src/runtime/thread-worker.ts | 6 +++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/runtime/process-worker.ts b/src/runtime/process-worker.ts index 3b1977f..f60b388 100644 --- a/src/runtime/process-worker.ts +++ b/src/runtime/process-worker.ts @@ -1,6 +1,5 @@ import { ChildProcess, fork } from 'child_process' import { MessagePort, TransferListItem } from 'worker_threads' -import { dirname, resolve } from 'path' import { fileURLToPath } from 'url' import { TinypoolChannel, @@ -21,9 +20,11 @@ export default class ProcessWorker implements TinypoolWorker { waitForExit!: Promise initialize(options: Parameters[0]) { - const __dirname = dirname(fileURLToPath(import.meta.url)) - - this.process = fork(resolve(__dirname, './entry/process.js'), options) + // fix https://github.com/tinylibs/tinypool/issues/71 + this.process = fork( + fileURLToPath(import.meta.url + '/../entry/process.js'), + options + ) this.threadId = this.process.pid! this.process.on('exit', this.onUnexpectedExit) diff --git a/src/runtime/thread-worker.ts b/src/runtime/thread-worker.ts index ce4c3a8..ba3a8b2 100644 --- a/src/runtime/thread-worker.ts +++ b/src/runtime/thread-worker.ts @@ -9,7 +9,11 @@ export default class ThreadWorker implements TinypoolWorker { threadId!: number initialize(options: Parameters[0]) { - this.thread = new Worker(fileURLToPath(import.meta.url + '/../entry/worker.js'), options); + // fix https://github.com/tinylibs/tinypool/issues/71 + this.thread = new Worker( + fileURLToPath(import.meta.url + '/../entry/worker.js'), + options + ) this.threadId = this.thread.threadId } From 5417ba6c7d2e3244d17b8a24c18e7681cbd5caa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Fri, 15 Sep 2023 07:37:17 +0300 Subject: [PATCH 3/4] chore: remove unnecessary comment --- src/runtime/process-worker.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/runtime/process-worker.ts b/src/runtime/process-worker.ts index f60b388..8830c23 100644 --- a/src/runtime/process-worker.ts +++ b/src/runtime/process-worker.ts @@ -20,7 +20,6 @@ export default class ProcessWorker implements TinypoolWorker { waitForExit!: Promise initialize(options: Parameters[0]) { - // fix https://github.com/tinylibs/tinypool/issues/71 this.process = fork( fileURLToPath(import.meta.url + '/../entry/process.js'), options From 5c230662e4b372d2b7a5a36d18cca1b133fb7a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Fri, 15 Sep 2023 07:37:24 +0300 Subject: [PATCH 4/4] chore: remove unnecessary comment --- src/runtime/thread-worker.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/runtime/thread-worker.ts b/src/runtime/thread-worker.ts index ba3a8b2..a79da12 100644 --- a/src/runtime/thread-worker.ts +++ b/src/runtime/thread-worker.ts @@ -9,7 +9,6 @@ export default class ThreadWorker implements TinypoolWorker { threadId!: number initialize(options: Parameters[0]) { - // fix https://github.com/tinylibs/tinypool/issues/71 this.thread = new Worker( fileURLToPath(import.meta.url + '/../entry/worker.js'), options