Repository navigation
fix(desktop): make quit bounded and re-entrancy safe so SIGTERM and Cmd+Q always exit - #4787
Conversation
…md+Q always exit before-quit resumed the quit with app.quit() from a microtask inside the before-quit emit; Electron's Browser::Quit() then overwrote is_quitting_ and a never-activated install stayed alive with no window after SIGTERM. A quit that arrived mid-startup rejected the whenReady chain and its showErrorBox modal blocked the main thread forever. The shutdown screen navigated to a data: URL, which spawns a renderer and trips CHECK_EQ(program, child_path) once the app bundle is gone from disk. The quit sequencer always resumes from a fresh macrotask, caps the service teardown at 10 s, quits on rejection, and falls back to app.exit() when will-quit never arrives. The shutdown screen replaces the document in place. Startup and renderer-crash dialogs stand down while a quit is in progress.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
|
Composed from four publisher renders ( Test evidence — a fresh enterprise install exits within 15s of SIGTERM without crashing — ✅ passedSHA 73e45c9 · engine v1 ✅ passed · 2 expectations passed · 0 failed · 0 pending verdict passed · 0 user observations · 0 probes · steps 0/0 ℹ️ ASSERTION — 1. A fresh enterprise install exits with code 0 within 15000ms of SIGTERMexit code 0 signal null after 170ms
ℹ️ ASSERTION — 2. No crash report appears in /Users/guillaume/Library/Logs/DiagnosticReports for the fresh install after SIGTERMno new OpenWork*.ips
Test run created 2026-09-10T07:50:39.085Z · Source: Test evidence — a fresh enterprise install exits within 15s of normal quit without crashing — ✅ passedSHA 73e45c9 · engine v1 ✅ passed · 2 expectations passed · 0 failed · 0 pending verdict passed · 0 user observations · 0 probes · steps 0/0 ℹ️ ASSERTION — 1. A fresh enterprise install exits with code 0 within 15000ms of normal quitexit code 0 signal null after 82ms
ℹ️ ASSERTION — 2. No crash report appears in /Users/guillaume/Library/Logs/DiagnosticReports for the fresh install after normal quitno new OpenWork*.ips
Test run created 2026-09-10T07:50:46.123Z · Source: Test evidence — a activated enterprise install exits within 15s of SIGTERM without crashing — ✅ passedSHA 73e45c9 · engine v1 ✅ passed · 2 expectations passed · 0 failed · 0 pending verdict passed · 0 user observations · 0 probes · steps 0/0 ℹ️ ASSERTION — 1. A activated enterprise install exits with code 0 within 15000ms of SIGTERMexit code 0 signal null after 158ms
ℹ️ ASSERTION — 2. No crash report appears in /Users/guillaume/Library/Logs/DiagnosticReports for the activated install after SIGTERMno new OpenWork*.ips
Test run created 2026-09-10T07:50:50.724Z · Source: Test evidence — a activated enterprise install exits within 15s of normal quit without crashing — ✅ passedSHA 73e45c9 · engine v1 ✅ passed · 2 expectations passed · 0 failed · 0 pending verdict passed · 0 user observations · 0 probes · steps 0/0 ℹ️ ASSERTION — 1. A activated enterprise install exits with code 0 within 15000ms of normal quitexit code 0 signal null after 143ms
ℹ️ ASSERTION — 2. No crash report appears in /Users/guillaume/Library/Logs/DiagnosticReports for the activated install after normal quitno new OpenWork*.ips
Test run created 2026-09-10T07:50:55.488Z · Source: |
Warden review summary — ClearNative findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (80006 ms), confidentiality-review (107970 ms), spec-provenance-review (129901 ms), desktop-den-sync-review (124046 ms). Blockers
Advisories
Needs recheck
Observed review-thread metrics
Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority. |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (ad3d5b91ecd849beec96c14b99e1cf872475966a). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (73e45c95906f78e65f93ddf7ad928181bc04befb). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
Symbolicated cause
Five
OpenWork Enterprise-*.ipsreports (0.18.42–0.18.45, Electron 43.2.0 arm64, dSYM UUID4C4C44E7-5555-3144-A15C-8DC0CC013F82matched) all fault atprogram = base::MakeAbsoluteFilePath(GetProgram())isrealpath(): it returns empty once the helper binary no longer exists on disk. Two field triggers, both a Chromium relaunch of a dead helper while the main loop was still running:GpuProcessHost::LaunchGpuProcess←VizProcessTransportFactory::OnGpuProcessLost←HostFrameSinkManager::OnConnectionLostUtilityProcessHost::Start←ServiceProcessHost::Launch<NetworkService>←NetworkConnectionTracker::Initialize(Mojo pipe error)Controls on a packaged build from this branch: bundle intact +
SIGKILLGPU helper → relaunch succeeds, no crash; bundle removed +SIGKILLGPU helper → SIGTRAP at the same CHECK (variant A reproduced); bundle removed + SIGTERM → SIGTRAP at the same CHECK via a third trigger, our ownshowShutdownScreen()→loadURL("data:…")→RenderFrameHostManager::CreateSpeculativeRenderFrameHost. The crashed processes were leaked eval launches (started 15:17–15:22, killed 16:54) whosecp -Rcbundle copies had already been removed by world disposal. The security CHECK is Electron's and stays; this PR removes the one child launch our quit path itself started and makes the quit finish so nothing lingers past the bundle.Why the app did not exit (three bugs in our code)
app.quit(). On an install with nothing running, thebefore-quitteardown settled without leaving the microtask queue, soapp.quit()ran insideEmit("before-quit")of the signal-drivenBrowser::Quit(). The nestedQuit()setis_quitting_ = trueand closed the windows; the outer one returnedprevent_default = trueand overwrote it withfalse.OnWindowAllClosedthen took the non-quitting branch →window-all-closed→ macOS kept a windowless process forever (released 0.18.46: fresh--blank-slate+ SIGTERM never exits). Deferring the quit to a macrotask on the same build exits in ~160 ms.app.whenReady().then(async …)still awaitsmainWindow.loadFile()aborts the load (ERR_FAILED (-2)), the chain rejects, and its.catchcalleddialog.showErrorBox— a synchronous-[NSAlert runModal]that blocked the main thread (sampled) before reaching its ownapp.quit(). No JS failsafe can run behind a modal.data:navigation) — the third trigger above.Fix (smallest diff)
apps/desktop/electron/quit-sequence.mjs: single-shot sequencer — always resumesapp.quit()from a fresh macrotask, caps the service stop at 10 s, quits on rejection/throw, falls back toapp.exit(0)5 s after a quit that never reacheswill-quit.main.mjs: sequencer wired tobefore-quit/will-quit; shutdown screen replaces the document in place (document.open/write, same renderer); startup.catchandrender-process-gonerecovery stand down while a quit is in progress.SurfaceHandle.exit(local host resolves the spawned process's exit code/signal), worlddesktop-quit-path.ts, journeydesktop-quit-path.e2e.test.ts(placementlocal), newdesktop-quit-enterprisephase inpackaged-smoke.mjs.Repro matrix (packaged enterprise build, macOS 26.6.2 arm64,
settle 20 s)origin/dev)Browser.close(Cmd+Q path)Browser.closeelectron_browser_client.cc:522, by design), not reachable from app codeProof
pnpm --dir apps/desktop testis a no-op off macOS, same onorigin/dev); 7 new inquit-sequence.test.mjsOPENWORK_EVAL_ELECTRON_BINARY=<before build> pnpm evals:e2e desktop-quit-path --localstill running after 15002ms)OPENWORK_EVAL_ELECTRON_BINARY=<this build> pnpm evals:e2e desktop-quit-path --localpackaged-smoke→desktop-quit-enterprisephase (run 34451642113)skipped — needs: macOS DiagnosticReports (linux has none)pnpm --filter @openwork/desktop typecheck:electronJourney runs on the PR head
73e45c959are published in the test-evidence comment (four sections). Lane: local. The journey isplacement: 'local'like its packaged siblings — it needs the macOS packaged binary and reads~/Library/Logs/DiagnosticReports; on Linux the crash-report half recordsskipped — needs: macOS DiagnosticReportsand the exit signal is the witness.Not done here: no
.github/changes; no host updater/ShipIt/defaults changes (eval launches run with a redirectedHOME).