Repository navigation
fix(update): refuse a stage or offer from a channel the user left - #33771
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: recording the channel on each offer and stage, then checking it in one guard, fixes the root cause the description names, and both callers of the gate handle the new Notes
[DESIGN-REVIEWED] 987fa1d Description read[DESCRIPTION-READ] fbc16c7894eafd3611d5d55f02216f9edaeb5df70986e1e56c64673946f292f5 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 |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS This PR adds no renderer control. The only new surface is one native quit-time notice with no buttons, and the description quotes its text in full. That text says what happened and what comes next. Notes
[UX-REVIEWED] 987fa1d Description read[DESCRIPTION-READ] 3bfb059829857a492ee3128547e29a4b940f4f58d9fa0082b1a0cb73c47073c3 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 Nothing blocks: the channel guard is fixed where the defect comes from (a stage or offer with no record of its source channel), under linked issue #33718. The riders are small, declared, and each fixes a bug of its own. Notes
What this change shipsInventory (8 items) — 5 justifiedIntent: a desktop update never installs or downloads a build from a release channel the user left, even when the new channel's feed is down. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 987fa1d Description read[DESCRIPTION-READ] 9eac1087f1a6a3a1c4abdea6f2683157c7732f498d19bf0950a44a369d3d6d37 That sha256 names the PR description this verdict read. 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: |
858f7ba to
3d1aa05
Compare
The desktop freshness gate refused a build from a channel the install no longer follows only when the switch landed during its own wait: every check re-points the feed's channel first, and nothing recorded where the staged bytes or the offer came from. A switch made before the click, followed by a feed that fails or hangs, let fail-open install or download the old channel's build. The offer and the stage now carry the channel whose feed served them, and one guard compares that, and the channel the judging check was sent to, with the selected channel. A build the selected channel also serves is taken over by that channel's check and still installs. The refusal is its own verdict, so the quit path names the channel change instead of a withdrawal. A Retry after an installer failure re-arms the before-quit listener, so a quit pressed during its wait is held as it is on the first click. The Electron suites tick FRESHNESS_CHECK_TIMEOUT_MS instead of a copy of it, and one test pins its documented 8s.
3d1aa05 to
987fa1d
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approve on 987fa1d. I read the whole diff (874 lines). This closes #33718.
- Main already refuses a stage when the channel changes during the freshness wait (
refuseStageFromChangedChannel). This PR recordsstagedChannel/foundChannelwhere the bytes and the offer came from. The same refusal then also covers a switch made before the click. That closes a gap in an existing rule, so it adds no new strictness. Fail-open on the followed channel is unchanged, and the "unchanged channel still installs fail-open" test still pins it. - A promoted release that the selected channel also serves takes the stage over (
stagedChannel = feedChannelon the same-version branch), so it still installs. That has a test. - The new
channel-changedverdict and its quit notice replace the false "withdrawn or superseded" text. applyUpdateAndRestartre-arms thebefore-quitlistener with remove-then-once, so a Retry can't register it twice.- The suites tick
FRESHNESS_CHECK_TIMEOUT_MS, and one test pins 8s. - The product code has no regex. The
assert.matchcalls are in tests only. - All 98 checks are green, and nobody else has an open change request.
…3771) The desktop freshness gate refused a build from a channel the install no longer follows only when the switch landed during its own wait: every check re-points the feed's channel first, and nothing recorded where the staged bytes or the offer came from. A switch made before the click, followed by a feed that fails or hangs, let fail-open install or download the old channel's build. The offer and the stage now carry the channel whose feed served them, and one guard compares that, and the channel the judging check was sent to, with the selected channel. A build the selected channel also serves is taken over by that channel's check and still installs. The refusal is its own verdict, so the quit path names the channel change instead of a withdrawal. A Retry after an installer failure re-arms the before-quit listener, so a quit pressed during its wait is held as it is on the first click. The Electron suites tick FRESHNESS_CHECK_TIMEOUT_MS instead of a copy of it, and one test pins its documented 8s. (cherry picked from commit 710d5e9)
Problem / Motivation
Goal: a desktop update never installs or downloads a build from a release channel the user has left, even when the newly chosen channel's feed is down or slow.
The freshness gate refuses a staged build from a channel the user stopped following only when the switch happens during the gate's own wait. Switch from insider back to stable while offline, then click "Install Update & Restart App" or quit after "Later": the gate's check on stable fails, fail-open installs what is staged, and that is the insider build. A Download click on an insider offer after the same switch downloads the insider build.
Three smaller defects in the same code: a Retry after a recovered installer failure exits on Cmd+Q without installing, the quit-time notice for a channel refusal says the update was "withdrawn or superseded", and the Electron tests hard-code the 8s bound, so changing it makes about thirty tests hang instead of fail.
Why it matters
Anyone who changes channel while offline or on a slow network, with an update already downloaded, gets the channel they left: a stable user on an insider build, or the reverse, and another update cycle to get back. The fail-open rule exists so a network outage never strands bytes the user chose; it was never meant to install bytes from a channel they turned away from. The quit notice then states a reason that is false, the Retry gap turns the user's Cmd+Q into a quit with the update not installed, and the hard-coded bound turns a future change to it into a CI job that never finishes.
Not a goal
website/electron/test/auto-update-install-timing.test.js"TEMPORAL: an installer failure with no held quit keeps the app open and stops holding" pins.feed-lane.js, from fix(desktop): stop Electron feed lane competing with policy provider on bundled installs #20095) also reads "withdrawn or superseded"; it is related and left as it is.What changed (motivation → approach → change)
Every build the lane can install now carries the channel whose feed served it, and one guard refuses a build from a channel the install no longer follows.
feed-lane.jsrecords the channel on the offer and on the stage;refuseFromChangedChannelinfreshness-gate.jsrefuses when that channel, or the check's, is not the selected one, on every exit ofverifyStageIsLatestand in the Download gatesupersededverdictchannel-changedverdict, and an "Update not installed" notice that names the channel changeapplyUpdateAndRestartarms the listener, once, when it starts8 * 1000FRESHNESS_CHECK_TIMEOUT_MS, and one test pins its valueA promoted release is the same build on both channels, so when the selected channel's check confirms the staged version, it takes the stage over and the install proceeds.
docs/build/release.mdlists the fourth outcome, the Download gate's channel rule and the quit notices, and namesupdates_step_up.pyas the arm endpoint's home.Backwards compatibility
Compatible: the updater's IPC surface and the states it pushes to the renderer are unchanged; the new verdict lives inside the feed lane, and the only new copy is one native notification.
The gate object stops exporting
refuseStageFromChangedChanneland exportsrefuseFromChangedChannel, which takes the build's channel, in its place. On main nothing outsidefreshness-gate.jscalled the old export (git grepoverwebsite/electron, tests included); the Download gate infeed-lane.jsis the first outside caller of the new one.Reader: website/electron/runtime/update/freshness-gate.js:verifyStageIsLatest -- release -- still calls
refuseStageFromChangedChannel, directly and throughstageVerdict, now a file-local wrapper overrefuseFromChangedChannel-- auto-update-freshness.test.js, auto-update.stage-lane.test.jsTests
website/electron/test/auto-update.stage-lane.test.js(new): a stage from the channel the user left is not installed when the selected channel's feed fails or hangs past the bound, nor on quit, where the notice names the channel change; a Download click on an offer from the left channel asks the selected channel instead; a stage the selected channel also serves still installs; a Retry after a recovered installer failure holds a quit pressed during its gateway stop; the bound is 8s.auto-update-freshness.test.js,auto-update.feed-lane.test.js: tickFRESHNESS_CHECK_TIMEOUT_MS. With the bound changed to 9s or to 5s, only the test pinning the 8s value fails (353 of 354 pass). The same 9s change without this PR fails 31 of 347, 22 of them by hanging until the 20s test timeout.feed-lane.jsandfreshness-gate.jsreverted toorigin/main, five of the new tests fail; the bound pin and the same-build install pass on both, as they should.test/auto-update*.test.js,test/electron-updater-error-identity.test.js): 354 passed.auto-update.stage-lane,auto-update-freshness,auto-update.feed-lane, 120 tests) passed 20 runs in a row one file at a time, 10 runs at--test-concurrency=4besideauto-update-install-timing.test.jsandelectron-updater-error-identity.test.js, and one run with--test-randomize --test-random-seed=1008851110.mainworktree run with the same settings. The worktree and pytest's basetemp sit inside~/.kiro/crew, where the product refuses to serve files, so these are the environment, not this change; CI decides.Proof: not provable -- frontend test (prove.py runs Python only)
Manual verification
The only new user-visible surface is a native OS notification drawn during quit, after the window is gone, so no browser capture can frame it. Its copy, pinned by the quit test above:
Screenshots / video
N/A: this diff changes no renderer surface; the new native notification's copy is listed under Manual verification.
Related Issues
Closes #33718
Related: #33721 tracks the side-effect-free feed read deferred from #21979 (#10333, which it was deferred to, closed as not planned; #22825 covers only the phase enum).
Sibling sweep
Swept: git grep -nE "feedChannel|currentChannel()" -- website/electron/runtime/update/
Sibling: website/electron/runtime/update/freshness-gate.js -- changed here
Sibling: website/electron/runtime/update/feed-lane.js -- changed here
Sibling: website/electron/runtime/update/state-reporter.js -- not affected -- recordLaneVersion stores the channel the fetch was sent to and compares it with currentChannel() at read time
Pattern harvest
Rule candidate: review-prompt
Pattern: a guard on where a cached artifact came from that compares the latest request's target instead of provenance recorded on the artifact when it was fetched
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)