Repository navigation
fix(desktop): bound gateway-launch.log reads and rotate it at shell start - #33652
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The diff adds and changes no user-visible control, label or state. The failure dialog shows the same 60-line launch-log tail; only the read and the on-disk rotation behind it changed. [UX-REVIEWED] 143fc38 Description read[DESCRIPTION-READ] 1b78c3e292e2ab8cea2d5dbd26e5e0a34043ee9045ab2c5c8fd499f36706f505 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The bounded tail read on its own meets the Goal. The rotation that rides along has a nameable harm (the file grows on disk without limit), and nothing in it is a second copy of an existing mechanism. Notes
What this change shipsInventory (6 items) — 4 justifiedIntent: when the gateway fails, the user sees the launch log's last lines straight away, however big the log has grown — a FIX.
[FIRST-PRINCIPLES-REVIEWED] 143fc38 Description read[DESCRIPTION-READ] 67098aebc085682f3710f88d80629de3e65ccf0cb3fe67737856316af58753d2 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. Rotating in the fresh-spawn path is sound, the bounded tail read fixes the stall at its cause, and both changes revert cleanly. Notes
[DESIGN-REVIEWED] 143fc38 Description read[DESCRIPTION-READ] 9288ac0acc8980eccfba5fabcb424786c43881ab12f6ab946b200328dac0cefb That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
251e310 to
ad42b30
Compare
|
Fixed in ad42b30. The finding was correct: rotating the launch log at shell boot, before The rotation now lives in the supervisor's fresh-spawn path ( Added |
…pawn The two gateway failure dialogs read the whole gateway-launch.log into one string to show its last 60 lines, and the log only ever appends with no cap. On a long-lived install the file reaches hundreds of MB, so the synchronous read in the main process stalls for seconds and spikes RSS the moment the gateway fails, and past V8's string limit the read throws and the dialog shows an empty log pane. Add readLogTail, which reads only the file's last 256 KiB, and route both reader sites through it. Add rotateLaunchLog, a size-gated one-generation rename in the shape native-logging.js already uses for chromium.log. Rotate in the supervisor's fresh-spawn path, just before the new gateway opens its log fd, so a shell that reuses a surviving gateway never rotates the log that gateway is still writing to (off Windows through an inherited descriptor, on Windows through the path). Closes #32719
ad42b30 to
143fc38
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (8 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the desktop shell reads only the last 256 KiB of gateway-launch.log for failure dialogs and rotates the log at a fresh gateway spawn; bounded change with tests.
…pawn (#33652) The two gateway failure dialogs read the whole gateway-launch.log into one string to show its last 60 lines, and the log only ever appends with no cap. On a long-lived install the file reaches hundreds of MB, so the synchronous read in the main process stalls for seconds and spikes RSS the moment the gateway fails, and past V8's string limit the read throws and the dialog shows an empty log pane. Add readLogTail, which reads only the file's last 256 KiB, and route both reader sites through it. Add rotateLaunchLog, a size-gated one-generation rename in the shape native-logging.js already uses for chromium.log. Rotate in the supervisor's fresh-spawn path, just before the new gateway opens its log fd, so a shell that reuses a surviving gateway never rotates the log that gateway is still writing to (off Windows through an inherited descriptor, on Windows through the path). Closes #32719 Co-authored-by: kirocrew-agent <agent@kirocrew.local> (cherry picked from commit 5a22d7e)
Problem / Motivation
Goal: The gateway failure dialog opens without delay and shows the launch log's real last lines, however long the app has been installed.
The desktop shell's
gateway-launch.logonly ever appends and has no size cap or rotation. The two places that show it to the user read the whole file into one string to keep its last 60 lines:runtime/gateway/failure-dialog.jsinsideshowUnrecoverableGatewayError, andgateway-supervisor.json the launch-failure path. On a long-lived install the file grows to hundreds of MB. The read is synchronous and runs in the main process the moment the gateway has failed, so the shell stalls for seconds and its resident memory spikes while the user is waiting on the error dialog. Past V8's string limit the read throws, the surroundingcatchswallows it, and the dialog shows an empty log pane.Why it matters
This hits a real install (a 350 MB launch log was reported, growing about 1.66 MB/day). The failure dialog is exactly where a user needs the last log lines, and that is where the whole-file read makes the shell slowest and eventually shows nothing.
Not a goal
What changed (motivation → approach → change)
Symptom: the failure dialog stalls the main process for seconds, spikes RSS, and eventually shows an empty log pane. Root cause: both dialog sites read the whole unbounded, ever-appending launch log to keep only its last 60 lines, and nothing caps the file.
Approach, reusing what the shell already has rather than adding a mechanism:
readLogTail(filePath, { fs, lines, maxBytes })ingateway-wait.jsreads only the final 256 KiB of a log and returns its last 60 lines via the existingtailLines; a log under the cap is read whole as before, so a short log shows the same lines. Both reader sites now call it.rotateLaunchLog(logPath, { fs, capBytes })ingateway-wait.jsdoes a size-gated, one-generation rename togateway-launch.previous.logwhen the log is over 10 MiB, matching the one-previous-generation shapenative-logging.jsalready uses forchromium.log. It runs once inmain.js, in the single-instance lock winner and before the gateway child is spawned inapp.whenReady. Only the lock winner rotates: a rejected second instance renaming the log would pull it out from under the primary's live gateway child, and on Windows the child holds the path so the rename fails. A log under the cap is left untouched, and the previous generation is renamed rather than deleted, so content users attach to reports stays on disk (at most two generations).docs/build/desktop-app.mdstates the cap and the bounded read.Why this change
The reporter asked for the failure dialog to open without delay and show the log's real last lines however long the app has been installed. The two fixes together do that: the bounded read removes the stall, the memory spike and the empty-pane failure, and the start-of-shell rotation bounds the file on disk. The reader fix changes no visible behaviour for a normal small log. The rotation keeps one previous generation rather than deleting anything, so it does not lose logs a user is told to send. Both ends reuse the existing
chromium.logrotation shape rather than adding a new mechanism.Backwards compatibility
Compatible: nothing that works today stops working.
tailLinesstays exported and unchanged; the two readers switch toreadLogTail, which returns the same 60-line tail for any log under 256 KiB.Removes nothing: the diff adds two helpers and re-points two internal callers. No path is hidden, no records or rows are deleted, no validator is tightened, and no public key or function is removed or renamed. The one on-disk effect is that a launch log over 10 MiB is renamed to
gateway-launch.previous.loginstead of growing unbounded; the content is retained, not deleted.Tests
website/electron/test/gateway-wait.test.js:readLogTailreturns the same 60-line tail as a whole read for a small log; reads only the file's tail (not the head filler) for a log far over the cap; returns "" for a missing file.rotateLaunchLogrenames over the cap, overwrites an existing previous generation, leaves an under-cap log untouched, and is a no-op on first launch.website/electron/test/crash-arming-order.test.js: assertsrotateLaunchLogis called exactly once, after the single-instance lock, and beforeapp.whenReady()— the ordering that keeps a rejected second instance from rotating the primary's log.website/electron/test/gateway-supervisor.failure-dialog.test.js: the fake fs now modelsstatSync/readSyncso the launch-log reclassification path exercisesreadLogTail.Proof: not provable -- frontend test (prove.py runs Python only). Verified manually: the new
gateway-wait.jstests fail onorigin/main(readLogTail/rotateLaunchLogare not functions) and pass on this branch; the ordering test fails whenrotateLaunchLogis placed at module load before the lock and passes with it inside the lock winner.Manual verification
On Linux, a node harness on a 300 MB log showed the old whole-file read at ~497 ms and +315 MB RSS versus the bounded read at ~1 ms and 0 MB, with an identical 60-line tail. We only have Linux; the Windows rename-under-open-handle concern is addressed by ordering (rotate before spawn), which
crash-arming-order.test.jsenforces at the call site.Screenshots / video
N/A — this diff touches no user-visible frontend surface (Electron main-process log handling and docs only).
Related Issues
Closes #32719
Sibling sweep
Swept:
git grep -nE "readFileSync\((gatewayLogPath|launchLogPath)" -- website/electron/Sibling: website/electron/runtime/gateway/failure-dialog.js -- changed here
Sibling: website/electron/gateway-supervisor.js -- changed here
Siblings: none beyond these two -- the whole-file launch-log read existed only at these two dialog sites; the on-disk append has no second writer this fix needs to touch.
Pattern harvest
Not generalizable: the two whole-file reads of an unbounded append-only log are specific to the launch-log dialogs;
chromium.logalready has the bounded/rotated shape this change mirrors, so there is no new class to ratchet.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)CI notes
website/electron/test/gateway-supervisor.runtime-owners.test.jsare present identically onorigin/main(platform-specific launchd assertions) and are unrelated to this change.