From 6b66b28e3d991c52afd92753a563b117ef8bb4f7 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Mon, 6 May 2024 16:36:48 +0900 Subject: [PATCH 1/2] =?UTF-8?q?FIX:=20node-tree-kill=E3=81=AE=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E5=87=A6=E7=90=86=E3=81=AE=E3=83=9F=E3=82=B9?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/electron/manager/engineManager.ts | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/backend/electron/manager/engineManager.ts b/src/backend/electron/manager/engineManager.ts index f957b91458..8ec30a9a5e 100644 --- a/src/backend/electron/manager/engineManager.ts +++ b/src/backend/electron/manager/engineManager.ts @@ -420,10 +420,13 @@ export class EngineManager { return undefined; } + const enginePid = engineProcess.pid; + if (enginePid == undefined) { + log.error(`ENGINE ${engineId}: Pid is ${enginePid}`); + return undefined; + } return new Promise((resolve, reject) => { - log.info( - `ENGINE ${engineId}: Killing process (PID=${engineProcess.pid})`, - ); + log.info(`ENGINE ${engineId}: Killing process (PID=${enginePid})`); // エラーダイアログを抑制 engineProcessContainer.willQuitEngine = true; @@ -434,12 +437,12 @@ export class EngineManager { resolve(); }); - try { - engineProcess.pid != undefined && treeKill(engineProcess.pid); - } catch (error: unknown) { - log.error(`ENGINE ${engineId}: Error during killing process`); - reject(error); - } + treeKill(enginePid, (error) => { + if (error != undefined) { + log.error(`ENGINE ${engineId}: Error during killing process`); + reject(error); + } + }); }); } From 0d2a3315dc990e40bf9f4361332cd449e87b8e48 Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Tue, 14 May 2024 03:30:22 +0900 Subject: [PATCH 2/2] Apply suggestions from code review --- src/backend/electron/manager/engineManager.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/electron/manager/engineManager.ts b/src/backend/electron/manager/engineManager.ts index 8ec30a9a5e..4d72eed73c 100644 --- a/src/backend/electron/manager/engineManager.ts +++ b/src/backend/electron/manager/engineManager.ts @@ -422,7 +422,11 @@ export class EngineManager { const enginePid = engineProcess.pid; if (enginePid == undefined) { - log.error(`ENGINE ${engineId}: Pid is ${enginePid}`); + // エンジン起動済みの場合来ないはず + // 万が一の場合はエンジン停止済みとみなす + log.error( + `ENGINE ${engineId}: Process PID is undefined, assuming closed`, + ); return undefined; } return new Promise((resolve, reject) => {