authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-03-03 22:43:39-08:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-03-04 09:58:22-08:00
log310fd0b187ec20930b2ac5cbc50bcc7ee653524c
treed6d026693700490412a5e67087395bfd95c272d4
parentdb94743220c18b10f0f7533c109f1cb2f5357f90

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

1 files changed, 5 insertions(+), 3 deletions(-)

apps/desktop/scripts/dev-electron.mjs+5-3
...@@ -14,6 +14,7 @@ const watchedDirectories = [...@@ -14,6 +14,7 @@ const watchedDirectories = [
14];14];
15const forcedShutdownTimeoutMs = 1_500;15const forcedShutdownTimeoutMs = 1_500;
16const restartDebounceMs = 120;16const restartDebounceMs = 120;
17const childTreeGracePeriodMs = 1_200;
1718
18await waitOn({19await waitOn({
19 resources: [`tcp:${port}`, ...requiredFiles.map((filePath) => `file:${filePath}`)],20 resources: [`tcp:${port}`, ...requiredFiles.map((filePath) => `file:${filePath}`)],
...@@ -183,9 +184,10 @@ async function shutdown(exitCode) {...@@ -183,9 +184,10 @@ async function shutdown(exitCode) {
183184
184 await stopApp();185 await stopApp();
185 killChildTree("TERM");186 killChildTree("TERM");
186 setTimeout(() => {187 await new Promise((resolve) => {
187 killChildTree("KILL");188 setTimeout(resolve, childTreeGracePeriodMs);
188 }, 1_200).unref();189 });
190 killChildTree("KILL");
189191
190 process.exit(exitCode);192 process.exit(exitCode);
191}193}