From eb8886e4ddd9cdb95728c710f64e8b8579be1e1d Mon Sep 17 00:00:00 2001 From: renxia Date: Thu, 23 Jan 2025 09:52:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(createChildProcess):=20=E4=B8=BB=E5=8A=A8?= =?UTF-8?q?=E9=80=80=E5=87=BA=E5=AD=90=E8=BF=9B=E7=A8=8B=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E5=8F=91=E9=80=81=20abort=20=E4=BF=A1=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/node/createChildProcess.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node/createChildProcess.ts b/src/node/createChildProcess.ts index 5de97d7..cadd5ab 100644 --- a/src/node/createChildProcess.ts +++ b/src/node/createChildProcess.ts @@ -29,9 +29,9 @@ export function createChildProcess(options: CreateThreadOptions, onMessage?: let heartbeat = 0; let heartbeatTimer: NodeJS.Timeout; const exit = () => { - controller.abort(); - if (!worker.killed) worker.kill(); clearInterval(heartbeatTimer); + // if (!worker.killed) controller.abort(); + if (!worker.killed) worker.kill(); }; worker.send(options); @@ -52,16 +52,16 @@ export function createChildProcess(options: CreateThreadOptions, onMessage?: if (onMessage) onMessage(info); if (info.end) { - exit(); resolve(info.data as never as T); + exit(); } }); worker.on('error', error => console.log(`[worker][${options.type}]err:`, error)); worker.on('exit', code => { if (options.debug) console.log(`[worker][${options.type}]exit worker`, code); - exit(); if (code !== 0) reject(code); + exit(); }); if (options.debug) {