From 2ea489a4c1932521687765961bf7e34f740b283f Mon Sep 17 00:00:00 2001 From: fengkx Date: Thu, 20 Jan 2022 00:14:26 +0800 Subject: [PATCH] fix: kill child process when parent exit --- source/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/index.ts b/source/index.ts index 4678ee34097..0fb27b10cab 100644 --- a/source/index.ts +++ b/source/index.ts @@ -271,6 +271,9 @@ async function startFetchProcess(restartTime: number): Promise { const child = fork(fetchJS, [], { execArgv }); + process.once('exit', () => { + child.kill(9); + }); child.on('message', function (message: Message | string) { if (typeof message === 'string') logger.info(message); else if (isSuccess(message)) {