[eric] outputs/quit: reap app builder child processes before killing the backend on windows so nsis upgrades stop hitting "cannot be closed"; bump 1.1.67

- root cause: window-all-closed called killBackend() (windows: taskkill /F) BEFORE before-quit could POST /shutdown-all, so the backend was dead before it could run stop_all(), orphaning the bundled vite node.exe; a running node.exe locks its own image at resources\node\x64\node.exe, so the next nsis upgrade cannot overwrite it and surfaces appCannotBeClosed via the file-lock retry path (extractAppPackage.nsh / installUtil.nsh), not the name-based app-running check
- windows-only because mac's killBackend sends SIGTERM, which lets uvicorn run its lifespan shutdown -> stop_all(); only since 1.1.64 because app builder first started spawning these children on windows in bf6d7a9 (before that they died with WinError 2)
- fix: drop the premature killBackend() in window-all-closed (will-quit still kills the backend, now AFTER the reap) and raise the pre-quit reap budget from 2s to 10s to cover stop_all's parallel taskkill (up to 5s) + 3s SIGTERM grace
- mac unaffected: will-quit already kills the backend; the app reap simply runs explicitly via /shutdown-all now instead of riding on SIGTERM timing

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Eric
2026-05-26 13:19:11 -07:00
co-authored by Claude Opus 4.7
parent cf74ada3c2
commit c0d0e012cc
2 changed files with 16 additions and 3 deletions
+15 -2
View File
@@ -1485,7 +1485,15 @@ app.on('web-contents-created', (_event, contents) => {
});
app.on('window-all-closed', () => {
if (!isDev) killBackend();
// Intentionally NOT killBackend() here. before-quit POSTs /shutdown-all
// so the backend reaps App Builder child processes (bundled node/vite,
// uvicorn) while it is still alive; will-quit kills the backend after.
// Killing it here first (on Windows that is taskkill /F, which skips
// uvicorn's graceful stop_all) orphans those children, and an orphaned
// vite node.exe keeps a lock on its own image at
// resources\node\x64\node.exe, blocking the next NSIS upgrade with
// "OpenSwarm cannot be closed". Mac's SIGTERM happened to run stop_all,
// which is why this never reproduced there.
app.quit();
});
@@ -1522,8 +1530,13 @@ app.on('before-quit', async (event) => {
if (drainingForQuit) return;
event.preventDefault();
drainingForQuit = true;
// 10s, not 2s: stop_all() reaps runtimes in parallel but each can take up
// to ~8s on Windows (taskkill /T /F up to 5s + a 3s SIGTERM grace). At 2s
// the backend got hard-killed mid-reap, orphaning the vite node.exe. The
// ceiling is only reached when an App Builder app is actually running and
// slow to die; with none active stop_all returns instantly.
try {
await postShutdownAllApps(2000);
await postShutdownAllApps(10000);
} catch (_) {}
app.quit();
});
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "openswarm",
"version": "1.1.66",
"version": "1.1.67",
"description": "OpenSwarm — AI Agent Orchestrator",
"author": "openswarm-ai",
"main": "main.js",