Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Wait for child process tree shutdown before forcing kill

Julius Marminge310fd0b187ec
diff --git a/apps/desktop/scripts/dev-electron.mjs b/apps/desktop/scripts/dev-electron.mjs
index 611f50858..5d8bbe111 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);
}