Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: node-tree-killのエラー処理のミスを修正 #2061

Merged
merged 2 commits into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/backend/electron/manager/engineManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,17 @@ export class EngineManager {
return undefined;
}

return new Promise<void>((resolve, reject) => {
log.info(
`ENGINE ${engineId}: Killing process (PID=${engineProcess.pid})`,
const enginePid = engineProcess.pid;
if (enginePid == undefined) {
// エンジン起動済みの場合来ないはず
// 万が一の場合はエンジン停止済みとみなす
log.error(
`ENGINE ${engineId}: Process PID is undefined, assuming closed`,
);
return undefined;
}
return new Promise<void>((resolve, reject) => {
log.info(`ENGINE ${engineId}: Killing process (PID=${enginePid})`);

// エラーダイアログを抑制
engineProcessContainer.willQuitEngine = true;
Expand All @@ -434,12 +441,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);
}
});
});
}

Expand Down
Loading