Repository navigation
Say why an update install failed instead of stalling for three minutes - #12224
Conversation
…r three minutes A failed `quitAndInstall()` threw away the updater's own error text and replaced it with a generic sentence. On a .deb Linux host the discarded text is the only record of the failed pkexec elevation and the exact `dpkg -i <path>` command the user needs, so nothing actionable reached the logs or the UI. Three fixes on one path: - `src/main/updater.ts:963` now appends the updater's cause (whitespace-collapsed, capped at 200 chars) to the install-failure status. A Windows signature verdict is passed through verbatim so `UpdateCard` still routes it to its own card instead of prefixing contradictory restart advice. - `performQuitAndInstall` calls `span.fail()` on the two abort paths that previously returned bare, so the `updater.install` span stops reporting Success for an install that never ran. - The remote-server reconnect loop now reads the failure the still-running server is already publishing through `updater.getStatus`, ending in about a second instead of burning the full three-minute reconnect budget and blaming a reconnect timeout. The probe is skipped on the first tick because the install RPC returns before the installer fires. Also deduplicates the repeated "has this version caught up" comparison into `hasReachedAppVersion`, and adds `break-words` to the remote-update dialog row that renders the now-longer text un-disclosed. Closes #11906 Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthroughThe updater preserves installer causes in generic failure messages, records structured failure diagnostics, and marks failed installation spans as 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@greptileai review |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/runtime/remote-server-update-coordinator.test.ts (1)
313-339: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a test for a genuine first-tick failure.
This test reaches the target version on tick 2, so
readRemoteServerInstallFailureis never called. The test does not exercise theprobedguard inrunRemoteServerUpdate, which exists specifically to suppress an error seen on the very first tick afterinstall().Add a test where
getRuntimeStatuskeeps returning the old runtime/version on every tick, andgetUpdaterStatusreports a matching-runtimeId error from tick 1 onward. Assert that the result is notfaileduntil tick 2, to confirm tick 1 is genuinely skipped rather than accidentally passing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8b85144d-1000-45ae-9fbc-0f1ab5c69fb9
📒 Files selected for processing (10)
src/main/updater.install-failure-cause.test.tssrc/main/updater.test.tssrc/main/updater.tssrc/renderer/src/components/UpdateCard.error-card.test.tsxsrc/renderer/src/components/settings/RemoteServerUpdateDialog.tsxsrc/renderer/src/runtime/remote-server-install-failure-probe.test.tssrc/renderer/src/runtime/remote-server-install-failure-probe.tssrc/renderer/src/runtime/remote-server-update-coordinator.test.tssrc/renderer/src/runtime/remote-server-update-coordinator.tssrc/shared/app-version.ts
…t wait inside its deadline Removes three trade-offs the first pass accepted: - the raw cause reached the update card unsanitized; it now goes through the same redactor the retained-package recovery card uses - a quitAndInstall that throws instead of dispatching still lost its reason - the reconnect poll could outlive its own three-minute budget by 25s The reconnect wait moves to remote-server-restart-wait.ts, which also keeps the coordinator under its 300-line budget. Co-authored-by: Orca <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8a51fbe7-303a-4fed-87ba-01bd3e30be54
📒 Files selected for processing (8)
src/main/updater.install-failure-cause.test.tssrc/main/updater.tssrc/renderer/src/runtime/remote-server-install-failure-probe.test.tssrc/renderer/src/runtime/remote-server-install-failure-probe.tssrc/renderer/src/runtime/remote-server-restart-wait.test.tssrc/renderer/src/runtime/remote-server-restart-wait.tssrc/renderer/src/runtime/remote-server-update-coordinator.tssrc/renderer/src/store/slices/remote-server-updates.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/renderer/src/runtime/remote-server-install-failure-probe.ts
- src/renderer/src/runtime/remote-server-install-failure-probe.test.ts
- src/main/updater.ts
Co-authored-by: Orca <[email protected]>
…rt-wait awaits The status RPC could spend the tick's whole budget and the install-failure probe would then start a second full one, letting a tick run ~2x past the deadline. Co-authored-by: Orca <[email protected]>
stablyai#12224) Surfaces the real install-failure cause instead of letting a failed elevation stall silently, and keeps the reconnect wait inside its total budget by recomputing the remaining time after each awaited RPC. Relates to stablyai#11906 — this fixes the observability half. The functional half (a .deb/.rpm host cannot elevate and can never self-update) is unchanged, so the issue stays open.
Summary
A failed
quitAndInstall()destroyed the only copy of the updater's own error text.handleQuitAndInstallFailure(src/main/updater.ts:959) received theErrorbut never used it — it sent a fixed sentence (getPreCommitInstallFailureMessage()) and recorded a breadcrumb withundefineddata. On the reporter's.debLinux host that discarded text is the only record of the failed pkexec elevation and of the exactdpkg -i '<pending path>'command needed to finish by hand, which is why nothing showed up under~/.config/orca/logs/.Three defects on one path, now fixed:
The cause is kept.
withInstallFailureCause(src/main/updater.ts:895) appends the updater's text — whitespace-collapsed and capped at 200 characters — to the generic copy, and the breadcrumb atsrc/main/updater.ts:969now carrieserrorType. A Windows signature verdict is returned verbatim with no prefix, becausesrc/renderer/src/components/UpdateCard.tsx:293-297classifies the whole error card (title, summary, primary action) offstatus.message; prefixing it would put "Quit and reopen Orca, then try again" on top of a security-stop card.The install span stops lying. On Linux
DebUpdater/RpmUpdaterand WindowsNsisUpdater, electron-updater re-dispatches the failure synchronously insidequitAndInstall(). Recovery ran, control returned, and the guard atsrc/main/updater.ts:781did a barereturn— a normal return out ofwithUpdaterSpanmeans exitSuccess, which is the 126 ms Success span in the report. It and the supervised-serve handoff branch (src/main/updater.ts:754) now callspan.fail()first.ActiveSpan.fail()finalizes the span, and the laterend()thatwithSpanissues is a documented no-op (contract atsrc/main/observability/tracer.ts:50-53, enforced by thepending.endedguard atsrc/main/observability/tracer.ts:204-207), so nothing throws and no recovery path re-runs.The remote client reads the failure instead of waiting it out.
installRemoteServerUpdate(src/main/updater.ts:1200-1214) buildsaccepted: trueand calls the un-awaitedquitAndInstall()before returning, so the RPC result cannot carry the failure. The reconnect loop (src/renderer/src/runtime/remote-server-update-coordinator.ts:268-302) polled onlygetRuntimeStatus, so a server that stayed up on the old version and was already publishing{state:'error'}throughupdater.getStatussat on "Restarting…" for the full three-minute budget and then blamed a generic reconnect timeout. The loop now also runsreadRemoteServerInstallFailure(src/renderer/src/runtime/remote-server-install-failure-probe.ts), which reports only when both the live runtime id and the snapshot's runtime id still match the process we asked to install.Note for the record: the report's "there is no timeout on that wait" is not accurate —
DEFAULT_REMOTE_SERVER_UPDATE_TIMING.reconnectTimeoutMsis three minutes (src/renderer/src/runtime/remote-server-update-coordinator.ts:69). The symptom was a three-minute stall ending in a misleading message, not an infinite hang. That deadline is kept as the backstop; no second timer was added.Two small pieces of housekeeping came along because the fix needed them: the repeated "has this version caught up" comparison (written out twice in the coordinator — once with a
targetVersion !== nullguard, once without, since that site's target is always a string) is nowhasReachedAppVersioninsrc/shared/app-version.ts, and the remote-update dialog row that renders this text un-disclosed gotbreak-words(src/renderer/src/components/settings/RemoteServerUpdateDialog.tsx:97), matchingMobileEmulatorAvailabilityDetails.tsx:47.Scope against #11906
The issue names two distinct defects. This PR fixes defect 2 only (observability / UX: the failure is detected and then swallowed, the span reports
Success, nothing surfaces in the client, and the dialog blames a reconnect timeout).Defect 1 is not fixed here. A
.deb/.rpmremote server still cannot elevate and therefore still cannot self-update; there is no privileged helper and no up-front "this host cannot elevate" detection. What changes is that the user is now told why, with thedpkg -i <path>command electron-updater produced, instead of being left to guess. The issue should stay open for the elevation work.Addresses #11906 (defect 2 — observability/UX). Does not close it.
ELI5
When Orca tried to install an update on this user's Linux machine, the install was blocked because it could not get administrator permission. The updater knew exactly what went wrong, but Orca threw that explanation away and showed a vague "couldn't restart" message instead. Worse, when the update was for a server the user connects to remotely, the app just showed "Restarting…" for three whole minutes before giving up and blaming the wrong thing — even though the server had been reporting the real reason the entire time. Now Orca keeps the explanation and shows it, and the remote case gives up in about a second with the actual reason. The user also gets the exact command they can run themselves to finish the install. Orca still cannot install the update for them on such a host — that part of the bug remains.
Fix proof
Before the fix, two throwaway repro files (
updater.bug-11906.test.ts,remote-server-update-coordinator.bug-11906.test.ts) failed as follows. Those files are not part of this diff — they were renamed off the issue number and folded into permanent suites, so this block is historical evidence and cannot be re-run from this branch:After the fix — the permanent homes are
src/main/updater.install-failure-cause.test.ts, plus new cases inremote-server-update-coordinator.test.ts, the newremote-server-install-failure-probe.test.ts, andUpdateCard.error-card.test.tsx:Both new guards were re-verified by mutation on this branch, and both do catch their regression:
installFailure = nullturns "repeats the install failure a still-running server is publishing" red (1 failed | 12 passed);probedfirst-tick gate turns "ignores an updater error that predates the install request" red (1 failed | 12 passed).No regressions
Main-process and shared suites — all 14
src/main/updater*suites,observability/tracer+observability/instrumentation, and the two shared suites (app-version,updater-windows-signature-check):All renderer suites that neighbour or import the changed files (
src/renderer/src/runtime/, all ofcomponents/settings/, bothUpdateCardsuites, and the remote-server-updates store slice):CI gate for file size, since
remote-server-update-coordinator.tsis not grandfathered and sits close to its 300-line budget (≈294 counted lines afterskipBlankLines/skipComments):Two pre-existing assertions in
src/main/updater.test.tscompared against the old fixed string and had to be updated. While doing so I found that one of them (recovers quit-for-update state on sync quitAndInstall error event without killing PTYs) hardcoded the non-macOS copy and therefore failed on macOS before this change — re-verified by running that single test against the PR's merge-base (8b311ae), where it fails withCould not restart to install the update. Quit and reopen Orca, then try again.. It now uses the same platform-aware constant the neighbouring Linux-recovery describe already used, so it passes on all three platforms.Trade-offs
sudo dpkg -i <path>discoverable. The text is not raw:withInstallFailureCauseruns it throughredactLinuxPackageInstallText(src/main/linux-package-install-diagnostic.ts:88), the same sanitizer the retained-package recovery card uses, so ANSI escapes, control bytes, the home directory, the user name, and any tracked package path are replaced before the cause is capped at 200 characters. The durable crash breadcrumb still carries classification only (no message, no path), and the one place this renders without a disclosure gotbreak-words. Regression test:updater.install-failure-cause.test.ts→ "redacts the cause the same way the retained-package card does".getUpdaterStatusnow takes an optionaltimeoutMs, andwaitForReplacementRuntimeclamps both poll RPCs tomin(10 s, time left before the reconnect deadline). The wait can therefore overshoot the three-minute deadline by at most one poll interval instead of ~25 s, and no second timer was added. In the broken case the loop still terminates in about a second instead of 180 s. Regression test:remote-server-restart-wait.test.ts→ "never lets a poll RPC outlive the reconnect deadline".quitAndInstallthat throws instead of dispatching used to lose its reason too. That gap is now closed: thecatchbranch ofperformQuitAndInstall(src/main/updater.ts:851) runs the samewithInstallFailureCauseonce the native call was reached. Regression test: "carries the cause when quitAndInstall throws instead of dispatching an error event".updater.installspans flip fromSuccesstoFailureon two abort paths. Only telemetry consumes span exits; nothing retries or alerts off them. This is a correction, but anyone eyeballing updater span success rates should expect the number to move.Verification limits
.deband Windows NSIS behaviours are reproduced through mockedelectron-updaterevents and real error strings, not on a real.debhost or a real Windows box. The reporter's actual failure (pkexec elevation on Linux Mint 21.3) was not reproduced end-to-end.Cross-platform
No keyboard shortcut, accelerator, shortcut label,
metaKey,path.join, shell invocation, or filesystem write is touched anywhere in this change.DebUpdater/RpmUpdaterdispatch the install error synchronously insidequitAndInstall(), so the cause is captured, the span exitsFailure, and the copy stays "Could not start the update installer. Orca remains open. (…)" since a restart is not known to help there.NsisUpdateralso dispatches synchronously, so both (1) and (2) apply. The one Windows-specific hazard is thatisWindowsSignatureCheckUnavailableFailure/isWindowsSignatureMismatchFailureare case-insensitive substring checks, so an embedded cause would change card routing.withInstallFailureCausehandles this explicitly by returning a matching cause verbatim, and there is a dedicated test for it in bothupdater.install-failure-cause.test.tsandUpdateCard.error-card.test.tsx.Failurespan exit: Squirrel delivers the error asynchronously after the span has already ended, andspan.fail()afterend()is a documented no-op. Stating that plainly rather than implying the behavior is uniform. The existing macOS guards (isMacInstallerReady,markMacQuitAndInstallInFlight,updateInstallCommitted,deferMacQuitUntilInstallerReady) and the post-commit rule that late errors must not recover are untouched, andupdater.mac-install.test.tsplus "does not recover quit-for-update state from late errors after install commit" stay green.transport; nothing assumes local execution. RPC rejections while the server process is being replaced stay swallowed by the loop's existingcatch {}(covered by "keeps waiting when the failure probe itself cannot be reached").GitCapabilityCacheare not in play. No GitHub- or GitLab-specific naming or behavior is involved.Performance
Negligible, and net-negative work on the broken path.
updater.getStatusRPC per 500 ms tick, and only when the original runtime id is still reachable after at least one completed tick. Successful updates that replace the process within one tick issue zero extra calls (that is what theprobedgate buys, on top of closing the false-positive window). An unreachable or already-replaced server issues zero extra calls. Calls are sequentialawaits, so there is no request pile-up. In the failure case the loop terminates in about a second instead of 180 s, i.e. strictly less SSH traffic than today.span.fail()calls are no-ops when no tracer sink is installed.failedentry, soonProgresscall counts are identical.hasReachedAppVersionis the same comparison chain that was previously inlined twice — one extra function call on a cold path.Security
RemoteServerUpdateTransportalready exposedgetUpdaterStatus(remote-server-update-coordinator.ts:50, used by the existingremote-server-updater-polling.ts), so there is no new transport plumbing and no new remote-callable surface.spawn,exec, or shell invocation anywhere in this diff. Thedpkgcommand that now appears in the message is text produced by electron-updater that is displayed to the user; Orca does not execute it.errorType), never the message, path, home directory, or stderr, matching the existinglinux_package_install_failedbreadcrumb policy. The redaction-based Linux recovery copy takes priority whenever a package artifact was retained, so the redacted path remains the norm.causepasses through the existingredactStringsink redactor like every other span.<p>— nodangerouslySetInnerHTML, no interpolation into markup or URLs.break-wordsis a layout-only utility.AI Review Report
Reviewed by independent subagents in a loop until clean, across two hostile lenses — correctness/regressions and cross-platform + remote + performance.
Follow-up pass: fewer trade-offs
A second review asked whether a design with fewer trade-offs exists. Three of the accepted trade-offs turned out to be artifacts of the first implementation rather than essential, and are now gone (see the updated Trade-offs list). All three of the non-blocking notes below are resolved by that pass:
withInstallFailureCausenow callsredactLinuxPackageInstallText, passing the tracked package path so the redaction is identical to the recovery card's;catchbranch discardingerror) — the post-nativecatchbranch now appends the cause the same way the event branch does.The reconnect wait moved out of
remote-server-update-coordinator.tsintosrc/renderer/src/runtime/remote-server-restart-wait.ts(waitForReplacementRuntime). That is a real seam — "wait for the replacement process, or report why it never came" — and it also takes the coordinator back from 305 counted lines (over its 300 budget once the clamp was added) to comfortably under it, without a ratchet bump.Alternatives evaluated and rejected:
UpdateStatusinstead of message sniffing, to keep the "Quit and reopen Orca" sentence on a Windows signature verdict. It would remove that trade-off, butUpdateCardclassifies HTTP/2, signature-unavailable, and signature-mismatch errors offstatus.messagetoday; giving all three a discriminant means touching everysendErrorStatuscall site inupdater.tsand its 14 suites. Disproportionate for a path electron-updater does not actually reach — Windows signature verification runs during download, not duringquitAndInstall.updater.installRPC result instead of polling for it. The RPC must return before the process quits, and on LinuxDebUpdater.doInstallrunsspawnSync, so awaiting the outcome would hang the successful path until the client's 15 s RPC timeout. Strictly worse..deb/.rpmhosts up front (triage sketch item 4, the other half of the issue)..debself-update works on hosts with a usable polkit agent; a blanket block regresses them, and a real "can this host elevate?" probe means spawning a privileged helper on a platform none of us can test here. Deliberately not attempted — see the issue note below.Non-blocking notes (3), recorded for transparency:
src/main/updater.ts—withInstallFailureCause(updater.ts:895) puts the rawError.messageoncurrentStatuswith no redaction, while the.deb/.rpmrecovery path inbuildLinuxPackageInstallFailureStatus(the redaction happens at updater.ts:941-944, in the function starting at updater.ts:915) runs the equivalent text throughredactLinuxPackageInstallTextunder the explicit comment "this text is shown in the card, so it gets the same redaction as retained stderr."redactLinuxPackageInstallTextis already imported inupdater.ts, so routing the raw cause through it would be cheap.src/main/updater.ts— Claim 1 of this PR ("the cause is kept") is applied only to the event-dispatch branch (handleQuitAndInstallFailure, updater.ts:959). The structurally similarcatchbranch ofperformQuitAndInstall(updater.ts:847-855) — the one that handlesgetAutoUpdater().quitAndInstall()throwing synchronously instead of re-dispatching through theerrorevent — still discardserrorand sends the baregetPreCommitInstallFailureMessage()whenbuildLinuxPackageInstallFailureStatusreturns null.src/main/updater.ts—withInstallFailureCause(updater.ts:895) sanitizes raw electron-updater/child-process text with onlyraw.replace(/\s+/g, ' ').trim().slice(0, 200). The repo already has a purpose-built sanitizer for exactly this text —redactLinuxPackageInstallTextinsrc/main/linux-package-install-diagnostic.ts, whose doc comment states the contract: "Turns arbitrary updater/child output into text safe to show locally: no ANSI, no control bytes, no home directory, no cached package path, bounded length."Made with Orca 🐋