Repository navigation
fix(desktop): a cancelled update download closes its transfer and a retry starts fresh - #292
Merged
Merged
Conversation
…etry starts fresh electron-updater 6.8.9 never handed its cancellation token to the requests doing the work. builder-util-runtime's doDownload ignored the onCancel it was given, so a cancelled full download rejected but kept its request and file open. DifferentialDownloader made its range requests with no token at all, so a cancelled differential download stayed pending and kept downloadPromise reserved, and Retry rejoined it. Both are patched to abort their requests on cancel, and the desktop waits for electron-updater to release the download before the cancel completes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t it gave up on The 60-second Promise.race freed the check but left the refresh RPC running, so a repeat check could overlap it. Atom commands now take an abort signal that interrupts their effect, and the update check aborts each request at its deadline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
Owner
Author
|
Randy reviewed head c6e8930. What's verified:
Two blockers:
|
…no further range Cancelling during electron-updater's one-second pause after every 100th range rejected the download, but the scheduled continuation still ran and opened the next range, racing the retry. The patched DifferentialDownloader now clears that pending pause on cancel, and every range or copy step checks the cancellation token before it resumes, in both the single and multiple range paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fresh stops at its deadline A single-flight command hands a joining caller the running promise, so the caller's abort signal never reached it and the update check kept spinning past its 60-second deadline. Each caller's wait now ends when its own signal aborts, and the shared refresh-providers run is interrupted after 60 seconds, so the request itself ends even when no caller can cancel it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Randy reviewed head da20a06 (round 2). Changes needed. Both round-one regressions are fixed. The old updater opened range 101 after a cancel in 3 of 3 runs, and the old joined update check missed its deadline. Targeted tests passed (92/92), and so did Blocking:
|
…at started it The 60 s deadline now belongs to the update check alone. Manual refreshes keep the server's own provider budgets, so a 75 s Antigravity model discovery is no longer cut off. A single-flight run gets its own AbortController. Each caller's signal only ends that caller's wait, and the run is cancelled once the last waiter leaves. runAtomCommand keeps the two-argument call when there is no signal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's command scheduler already counts the waiters on a shared run, so this branch takes it and adapts updateCheck to its API. Upstream's resumable full download (pingdotgg#38038) stopped handing doDownload an onCancel, which left a cancelled request open again; the electron-updater patch now gives it one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er resets its connection A stopping owner can accept the launcher's reconnect and then reset it while it releases the port. Only ECONNREFUSED was transient, so the launcher exited with ECONNRESET instead of moving the session; this made the owner-handover test fail on CI. Treat a reset during the handshake like a retiring owner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Randy's round-2 review of #287 (#287) found two problems with how a stalled update gets cancelled. #287 had already merged, so the fixes land here.
downloadPromisereserved, so Retry joined the cancelled download. Cancelling a full download rejected the promise but left the HTTP request open.Promise.racereturned, but the refresh RPC kept running, so a repeat check could overlap it.Randy's review of this PR found two more:
refreshProvidersis single-flight, so the scheduler hands a second caller the running promise and never applies that caller's abort signal. A check that joined a stalled refresh started elsewhere waited on it forever, and nothing ended the shared RPC.Randy's second review found three more:
runAtomCommandalways passed a third argument. The provider snapshot and VCS revalidation suites assert the two-argument call, so CITestfailed.Root cause in electron-updater
HttpExecutor.doDownloadin builder-util-runtime 9.7.0 receivesonCancelfromdownload/downloadToBufferbut never calls it. On cancel,createPromiserejects while the request keeps going. Nothing ends the file stream either, becausepipe()never ends its destination when the response is aborted.DifferentialDownloadercreates its range requests throughhttpExecutor.createRequestand never passes them the token. The single-range path, the multi-range path andreadRemoteBytesall do this. A stalled range request ignores the cancel, sodoDownloadUpdatestays pending andAppUpdater.downloadPromisestays set.downloadUpdatethen returns that same promise to the next caller.setTimeout. Nothing checks the token before a step resumes, so a continuation scheduled before the cancel runs after it.Effect.tryPromisereturns as soon as it is interrupted. electron-updater clearsdownloadPromiseonly after it finishes its async temp-file cleanup, so a Retry that came straight away still joined the old download.Fix
patches/builder-util-runtime@9.7.0.patch, registered and pinned inpnpm-workspace.yaml:doDownloadaborts its request on cancel, and an aborted response destroys the file stream.patches/electron-updater@6.8.9.patchgains a change toDifferentialDownloader. It tracks its open requests, and on cancel it aborts them and rejects throughcancellationToken.createPromise.multipleRangeDownloadercreates its requests the same way. A cancel also clears the pending pause after the 100th range. Every range or copy step checks the token before it resumes, in both the single-range and multiple-range paths.ElectronUpdater.downloadUpdatecancels on interrupt and then waits for electron-updater's download promise to settle.raceFirstinDesktopUpdateswaits for the losing fiber, so the stall error and its Retry show only after electron-updater has released the download. The 5-minute backstop is unchanged. It still resets on everydownload-progressevent, and it can now actually stop the transfer.{ signal }. It flows throughrunAtomCommand,createRuntimeCommandanduseAtomCommandon web and mobile, and aborting it interrupts the command's effect, which interrupts the RPC. The shared update check (client-runtime/updateCheck.ts, used on web and mobile) gives each request an abort deadline in place of thePromise.race. A request that hits the deadline is still reported as "No answer after 60 seconds."AbortController, counts the callers waiting on it, and is cancelled only when the last one leaves. A caller with no signal never leaves, so a manual refresh keeps a shared run alive after the update check that started it gives up. The 60 s deadline belongs to the update check alone, and manual refreshes keep the server's provider budgets. The round-2timeoutoption on runtime commands is gone.runAtomCommandcallscommand.run(registry, input)when there is no signal, and passes{ signal }only when one is given.Tests
Each test fails without its fix and passes with it.
apps/desktop/src/electron/ElectronUpdater.test.ts, "ElectronUpdater stalled download". These tests use the real electron-updater singleton (LinuxAppImageUpdater) and the realElectronHttpExecutordownload code overnode:http. A local server serves the update.ElectronUpdater.downloadUpdate, check that the server sees the stalled connection close, then retry and check that the retry sends a new request.AssertionError: the cancelled request stayed open.AssertionError: the cancelled request stayed open. With only the retry assertion:AssertionError: the retry joined the cancelled download.the retry joined the cancelled download. That is what the wait inElectronUpdater.tsfixes.AssertionError: the cancelled download opened another range,actual: { _tag: 'Some', value: 3216 }. 3216 is the offset of range 101.packages/client-runtime/src/updateCheck.test.tscreateRuntimeCommandwhose effect never finishes. The test checks for "No answer after 2 seconds." and waits until the effect is interrupted. Before the fix the reason matches, but the effect is never interrupted and the test times out. After the fix it passes.Error: Test timed out in 5000ms.AssertionError: expected { _tag: 'Failure', … } to match object { _tag: 'Success', … }, because the check's abort interrupted the shared run.packages/client-runtime/src/state/server.test.ts, "lets a manual provider refresh outlast a minute" covers finding 5. It runs the realrefreshProviderscommand fromcreateServerEnvironmentAtomsagainst an RPC that answers after 75 s, on fake timers.{ _tag: "Failure" }with anInterruptcause at 60 s.providerSkills.test.ts("scans a missing snapshot once and skips a repeat inside the TTL") andvcsStatusRevalidation.test.ts("refreshes once per connection, shared by every subscriber, and again on reconnect") failed on da20a06 withexpected "vi.fn()" to be called with arguments: [ Anything, … ]. Both pass after the fix (30 tests).ElectronUpdater.test.ts(4), plusupdateCheck.test.ts,server.test.ts,runtime.test.ts,providerSkills.test.tsandvcsStatusRevalidation.test.tstogether (120).vp run check:changedpasses: format, lint, knip, typecheck of 41 packages, 5 test files, react compiler and unused patches.Merged with main (c3bee4a): main's command scheduler already counts the waiters on a shared run, so the client-runtime part uses it, and the per-caller deadline and joined-refresh tests pass against it unchanged. Upstream's resumable full download (pingdotgg#38038) stopped handing
doDownloadanonCancel, so a cancelled full download left its request open again; "a cancelled full download closes its request and a retry downloads again" failed on the merged tree. The electron-updater patch now passesonCancelso a cancel aborts the request, and both that test and upstream'sElectronHttpExecutortests pass.CI flake fixed (
packages/mcp-gateway): after the merge, "moves a running stdio session to the next owner" failed three runs in a row withconnect ECONNRESETorread ECONNRESET. It had also failed on main at ff92ac7 and f7ad11b. A stopping owner can accept the launcher's reconnect and then reset it while it releases the port, and the launcher only treatedECONNREFUSEDas transient, so it exited.connectMcpSessionnow mapsECONNRESETduring the handshake toGatewayRetiringError, so the launcher retries and starts or joins the next owner. The new test "joins the next owner when a stopping owner resets the connection" uses a listener that resets the first connection. Before the fix it failed withconnect ECONNRESET; after it, all 19 tests insharedGateway.test.tspass.🤖 Generated with Claude Code