Skip to content

Commit

Permalink
fix(createChildProcess): 主动退出子进程时不发送 abort 信号
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Jan 23, 2025
1 parent 0c89727 commit eb8886e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/node/createChildProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export function createChildProcess<T>(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);
Expand All @@ -52,16 +52,16 @@ export function createChildProcess<T>(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) {
Expand Down

0 comments on commit eb8886e

Please sign in to comment.