From 310fd0b187ec20930b2ac5cbc50bcc7ee653524c Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 3 Mar 2026 22:43:39 -0800 Subject: [PATCH] Wait for child process tree shutdown before forcing kill - add `childTreeGracePeriodMs` constant for shutdown timing - await grace period after `TERM` before sending `KILL` to avoid dev process leaks --- apps/desktop/scripts/dev-electron.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/desktop/scripts/dev-electron.mjs b/apps/desktop/scripts/dev-electron.mjs index 611f50858315e86366049229d897e0099c35c07a..5d8bbe1116e2a5e7c9587f65c22d75c391477ad1 100644 --- a/apps/desktop/scripts/dev-electron.mjs +++ b/apps/desktop/scripts/dev-electron.mjs @@ -14,6 +14,7 @@ const watchedDirectories = [ ]; const forcedShutdownTimeoutMs = 1_500; const restartDebounceMs = 120; +const childTreeGracePeriodMs = 1_200; await waitOn({ resources: [`tcp:${port}`, ...requiredFiles.map((filePath) => `file:${filePath}`)], @@ -183,9 +184,10 @@ async function shutdown(exitCode) { await stopApp(); killChildTree("TERM"); - setTimeout(() => { - killChildTree("KILL"); - }, 1_200).unref(); + await new Promise((resolve) => { + setTimeout(resolve, childTreeGracePeriodMs); + }); + killChildTree("KILL"); process.exit(exitCode); } -- 2.54.0