Repository navigation
fix(update): guard startDownload during an install window (#10282) - #17752
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Confirm a manual Download click during the install or quit window can go silently unanswered: the guard logs and returns without emitting anything. Not justified as shipped
What this change shipsInventory (3 items) — 2 justifiedIntent: stop the desktop updater from leaving the gateway stopped and the dashboard dead when an automatic download races an Install. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] ad0a200 Description read[DESCRIPTION-READ] cc23457ff4654d03e09b6528dafc2378e5e3cf0d31a50c772ef70986365a1534 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Check that the renderer clears any "downloading" spinner when a manual download request is silently dropped during an install. [UX-REVIEWED] ad0a200 Description read[DESCRIPTION-READ] 2fa91d3dd679269b70200521bc41a66e5702a88118d9f678480c58fb9d2fd54a 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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that a manual [DESIGN-REVIEWED] ad0a200 Description read[DESCRIPTION-READ] 8661b642a141976a248d8e231617e36d9474994d9f3bffa75a463e584444eea8 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: |
c7c59b5 to
c343af8
Compare
c343af8 to
3652d2f
Compare
|
The SAST (Semgrep) check reports 3 findings, but none are introduced by this PR. This PR's diff is JavaScript only (
They are attributed to this PR only because the Semgrep job's baseline merge-base could not resolve on the shallow checkout (its log prints |
A feed check already in flight when the user clicks Install can return a NEWER build and fire an automatic supersede-download from the update-available handler WHILE the install dispatch is stopping the gateway. startDownload only guarded `if (downloading)`, so the automatic call set `downloading = true` over the top of `installing`; the post-stopGateway error handler then derived phase "download" instead of "install" and skipped the install-phase abort that restores the stopped gateway, leaving a dead dashboard. Refuse startDownload while installing || quitHandled, the same way safeCheck() already refuses during install activity. Keep the existing booleans. Adds a regression test that fails without the guard. This replaces the earlier phase-enum approach after a lane audit: the issue's premise of ~15 lifecycle booleans does not hold on main (only four exist), so the minimal fix is the missing guard, not a lattice rewrite. Fixes #10282
3652d2f to
ad0a200
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
This fixes the race where a feed check still in flight when the user clicks Install fires an automatic supersede-download mid-dispatch, sets downloading = true over installing, and makes the error handler pick the "download" phase. That phase skips the install-phase abort that restarts the gateway. The root cause is solved: startDownload was the one install-aware entry point without the installing || quitHandled guard that safeCheck() and the poll timer already have, and website/electron/runtime/update/feed-lane.js:190 adds exactly that guard before any state is touched. I read the full diff and the flag handling in feed-lane.js at ad0a200. installing is reset by the error and abort paths, and quitHandled by the retraction path, so the guard cannot wedge later downloads after a failed or withdrawn install. The new test parks install() inside a gated stopGateway, fires update-available, and asserts downloadUpdate was never called, which would fail on base. All checks are green, the GPT and Opus lanes report no findings, and Design, UX and First Principles all PASS. The change is small and scoped, base is main, and there are no open change requests. — crew-pr-reviewer
Problem / Motivation
Goal: Stop the desktop auto-updater from leaving the gateway stopped (a dead dashboard) when an automatic download races an in-progress install.
A feed check that is already in flight when the user clicks Install can return a NEWER build and fire an automatic supersede-download from the
update-availablehandler while the install dispatch is stopping the gateway. Onmain,startDownloadguarded onlyif (downloading)— it had no guard for the install window — so the automatic call setdownloading = trueover the top ofinstalling.Why it matters
The install dispatch stops the gateway on purpose and hands off to the platform installer. The post-
stopGatewayerror handler derives the phase asdownloading ? "download" : installing ? "install" : "check", so withdownloadingwrongly set a failure landing during the stop window is misattributed to the download phase and skips the install-phase abort that restores the stopped gateway. The user is left with a stopped gateway and a dead dashboard. It is a narrow race (check in flight + auto-download on + Install clicked in that window) but a severe outcome.Not a goal
downloading/installing/quitHandledlifecycle booleans into a phase enum. Issue refactor(update): replace initAutoUpdate's boolean lattice with an explicit phase enum #10282 proposed that, but its premise — "about fifteen independent booleans" — does not hold on currentmain: only four lifecycle flags exist (downloading,installing,quitHandled,checking); the machinery the issue cited came from the unmerged fix(update): always install the newest build, never a superseded download #9367 and never landed. The real defect is the single missing guard, so the enum rewrite is out of scope here.isReady()behaviour.Why this change
startDownloadnow refuses whileinstalling || quitHandled, exactly the waysafeCheck()already refuses during install activity. The existing booleans are kept; the change is one guard clause plus one regression test. This is the minimal fix for the race described above, in place of the broader phase-enum refactor the issue originally requested (see "Not a goal").What changed (motivation → approach → change)
Motivation:
startDownloadwas the one install-aware entry point missing the install-window guard thatsafeCheckalready had, so an automatic download could start mid-install and corrupt the error-phase attribution. Approach: add the same guardsafeCheckuses rather than rework the lifecycle flags, since the set of flags is already small and the defect is a single missing check. Change:website/electron/runtime/update/feed-lane.js:startDownloadreturns early wheninstalling || quitHandled, before it can setdownloading = true.website/electron/test/auto-update.test.js: one regression test that parks the install dispatch inside a gatedstopGatewayand asserts an automaticupdate-available-triggered download is refused.Backwards compatibility
Compatible: adds one guard clause and a test; renames nothing, removes nothing, changes no observable state. An automatic download that previously could race an install dispatch is now refused in that window; outside the install window
startDownloadis unchanged.Removes nothing: this diff hides no path, deletes no records, tightens no validator, and removes or renames no key or public function — it adds a guard clause and a test.
Tests
an automatic download fired during an install dispatch is refused (#10282)(website/electron/test/auto-update.test.js), which locks in thatstartDownloadrefuses while an install dispatch holds the lifecycle. It is proven to FAIL onmainwithout the guard (the automaticdownloadUpdateruns) and pass with it.website/electronnode:testsuite passes locally (the suite CI's Electron Shell Tests job runs): 2438 pass, 0 fail, 4 skipped.Manual verification
N/A — unit coverage sufficient. The change is a single guard clause fully exercised by the new regression test, which fails without it.
Reproduction
The regression test fails on
main(no guard — the automatic download runs during the install dispatch) and passes with the guard. Onmainwith the guard removed, running only that test:With the guard in place the full
website/electronsuite passes: 2438 pass, 0 fail, 4 skipped.Related Issues
Fixes #10282
Pattern harvest
Pattern: a guard that re-derives "is an install underway?" by hand can miss an entry point —
safeCheckrefused during the install window butstartDownloaddid not. When several entry points must honour the same lifecycle window, each needs the same guard; a missing one admits exactly the interleaving the others exclude.Rule candidate: when more than one entry point acts on the same lifecycle state, factor the guard into one shared check (or helper) and call it from every entry point, rather than re-deriving the condition at each site where one can be forgotten.