Skip to content

fix: reject expired updater feed selections - #23160

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-09-25-updater-feed-attempt
Sep 26, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-09-25-updater-feed-attempt

Conversation

@nwparker

@nwparker nwparker commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​124 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​124
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

ELI5

An old update lookup can finish after its check has timed out and change which release a newer check uses. Ignore that old result so the newer check keeps its own release and retry settings.

What Changed

Capture the existing check ID before waiting for release readiness, then verify that it still owns the check before changing the feed, prerelease fallback or publishing-window state. Both callers already verify ownership before launching the updater; this closes the earlier mutation gap.

Controlled overlap Before After
Expired A writes v2 after B selected v3 1 write 0 writes; v3 retained
Native checks launched in that scenario 1 1
Ordinary active feed selection 1 write 1 write

Why

Reusing the existing check identity protects all feed-state changes without adding another cancellation mechanism or changing timeout/retry policy. Canceling transport alone would still need an ownership check when results race with completion.

Linked Issue

Fixes #23159

Visual Proof

N/A — internal updater ownership fix with no layout change. Deterministic API tests show before/after state; no live update or rendered UI was exercised.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Seven new cases pass; substituting original source yields five failures and two passing controls. All 47 focused tests in five suites pass. Independent review adds ten cases (original: six failures, four passing controls) and repeats the seven permanent cases. It checks newer prerelease fallback, publishing-window retry/persistence, late rejection and active deadline rearming. Node typecheck, scoped lint/format and the changed-code quality gate pass.

Tested on macOS with fake clocks and mocked Electron, updater, persistence and release-feed boundaries under ORCA_BACKGROUND_LAUNCH=1. The reproduction deliberately holds readiness beyond 45 seconds; ordinary request deadlines are shorter. No live occurrence, real download/installer, Windows/Linux update or physical cancellation is established.

AI Disclosure

Review

Independent review approved. Merge risk: low-to-medium: a five-line guard reuses existing ownership state, but update-feed selection is sensitive. CI will cover isolated-branch checks.

Negative user-facing trade-offs: none identified. The old request still consumes resources until it settles. This is correctness-only; no latency, CPU, memory or native installation improvement is claimed.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No Git command, platform path, SSH execution, agent-status or wire-format change. Folder workspaces are unaffected. Native update behavior remains untested by these mocked regressions.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 34e985a2-1ecf-417b-bc56-6c66cfab21c6

📥 Commits

Reviewing files that changed from the base of the PR and between 8b7a2a5 and f9022ae.

📒 Files selected for processing (2)
  • src/main/updater.feed-attempt-lifetime.test.ts
  • src/main/updater/updater-release-feed.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

pinDefaultReleaseFeed now checks that its captured update-check attempt remains active after release-tag readiness completes. It returns 'not-available' without selecting a feed when the attempt is absent or inactive. New tests cover preflight results that arrive after the 45-second timeout, older results resolving after a newer feed selection, and feed URLs for ready and no-newer results.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to f9022

No actionable issue remains in the supplied review evidence; the change is ready to merge after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to f9022

The change prevents an expired update check from replacing a newer check’s release feed. No new security exposure was identified. A separate, pre-existing updater error path remains outside this fix, and its behavior under overlapping checks is not fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relevant shared state is the main-process updater’s selected feed and check launch for an application instance. The added code grants no new caller authority or arbitrary feed-URL input.

Trust Boundaries and Controls

  • observed — Release-tag lookup precedes feed selection. The new attempt-ID check prevents a late lookup from reaching feed mutations, while the two production callers independently gate updater launch.

Resilience and Maintainability Implications

  • inferred — A pre-existing global updater error could be attributed to the current check without proof that it originated there, allowing the unchanged fallback retry to use current shared state. Whether that overlap occurs in production is unresolved; it is not an identified regression from this PR.

Hardening Proposals

  • proposed — Associate fallback context and updater failures with their originating attempt before retrying or changing the shared feed; validate the behavior with overlapping event and promise failures.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: rejecting expired updater feed selections.
Description check ✅ Passed The description is complete and directly addresses the template. It explains the behavior, implementation, rationale, linked issue, visual proof, testing, review status, scope, and checklist. It also …
Linked Issues check ✅ Passed The PR satisfies the coding requirements in [#23159]. pinDefaultReleaseFeed captures activeUpdateCheckAttemptId before the readiness await. It returns before feed, prerelease-fallback, or publishi…
Out of Scope Changes check ✅ Passed The changes stay within [#23159]. The source change adds ownership validation for expired feed preflight results. The test file adds focused coverage for that behavior and for preserving active feed c…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — a one-line ownership guard added to the updater feed preflight, plus a new 7-case regression suite.

  • Stale preflight cannot repin the feed — pinDefaultReleaseFeed() captures activeUpdateCheckAttemptId before awaiting fetchNewerReleaseTagsWithReadiness(...) and returns 'not-available' without mutating pendingPrereleaseFallback, publishingWindowLastGoodCheck, or calling setFeedURL when that attempt is null or has been superseded.
  • New regression suite — src/main/updater.feed-attempt-lifetime.test.ts holds an old preflight past the 45s stall, has a newer check select v3, then resolves the old one with v2 and asserts v3 is retained with exactly one native launch; three expired-result variants and two active-behavior controls round it out.

I checked the two call sites (runBackgroundUpdateCheck, checkForUpdatesFromMenu): both begin the attempt synchronously immediately before calling this method, so the captured id is the caller's, and both already re-verify ownership before launching — the 'not-available' early return is therefore safely ignored. retryPrereleaseFallbackAfterMissingManifest has no await before its own ownership check, and the pinned/local-build paths set their feed without a readiness fetch, so the guard covers the only mutable preflight.

I also ran the suite both ways: 7/7 pass at head, and removing the guard produces 5 failures with 2 passing controls, so the new tests fail with the bug present rather than merely documenting current behavior.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor Author

Reviewed the CodeRabbit docstring-coverage warning. This repository explicitly requires concise comments limited to non-obvious reasoning (AGENTS.md), so I am declining the generic 80% docstring suggestion. The existing ownership/behavior comments and focused regression tests cover the decisions in this change. No code change is warranted for that style-only warning.

@nwparker
nwparker merged commit 2819faa into main Sep 26, 2026
34 checks passed
OrcaWin added a commit that referenced this pull request Oct 26, 2026
## ELI5

Orca can remember one release's ZIP filename and later follow “latest” into a newer release where that file does not exist. Resolve “latest” once, then keep the manifest and download on that concrete release.

## What Changed

- Replace the default-channel moving-feed fallback with a validated stable tag resolved from GitHub's `/releases/latest` redirect.
- Reuse the existing Electron `net.request` HEAD handling and platform manifest/asset readiness probes. `net.fetch` cancels manual redirects in real Electron, so it is not used for redirect discovery.
- Return a retryable check failure when a ready concrete fallback cannot be resolved, and reject fallback results belonging to an expired check.
- Update existing feed expectations and installer fixtures; cover stable fallback, Atom outages, unavailable fallback, late completions, redirect validation, and platform manifest selection.

## Why

The normal path already pins a tag, but Atom outages and no-newer results still installed a `/releases/latest/download` provider. That provider retains relative filenames while GitHub's redirect can move between checking and downloading. Correct release manifests alone cannot prevent the mismatch.

Credit to @brennanb2025 for the original tag-pinning fix in #1797, and @nwparker for the attempt-ownership guard in #23160, which this change extends across the fallback lookup. Also reviewed @sechan-netizen's #30952 and its review thread: its release-manifest validation is a complementary safeguard and remains separate because this race reproduces with correct manifests. No commits from that PR are copied here.

This PR adopts @brennanb2025's audited #34075 lint fix (splitting three files that already exceeded main's line limits), with Brennan retained as a co-author. Independent byte-level audits preserve the moved runtime bodies and test groups; the follow-up replaces five test-only assertions with typed calls and emits identical JavaScript. The standalone older PR remains unmerged after repeated daemon-test CI/order sensitivity; the combined tree here passed all CI, including that exact daemon test file (16 tests) in run 40398604134, job 121839803430.

## Linked Issue

Fixes #34034

Related reports: #15921 and #22621. The controlled race matches their URL signature and retry behavior; the reporter's original feed selection cannot be established without its logs.

## Visual Proof

N/A — updater feed selection only; no presentation change. Verified the HTTP behavior using the production fallback resolver and electron-updater 6.8.10 with unmodified v1.4.240/v1.4.241 manifests and a controlled local release server:

| Scenario | Result |
| --- | --- |
| Old moving provider: read 240 manifest, advance latest to 241, download | `v1.4.241/Orca-1.4.240-arm64-mac.zip`: 404 |
| Retry the old download without a new check | Same 404 |
| Fresh check | Correct 241 ZIP: 200 |
| Fixed fallback: resolve 240 tag, advance latest to 241, download | Correct 240 ZIP under tag 240: 200 |

No installer was executed and no app window was opened.

## Testing

- [x] I manually tested these changes locally
- [x] Automated tests added/updated

`ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2`: all 26 checks pass on the combined branch, including formatting, lint, typechecks, affected tests, and ratchets. The earlier updater-only run also passed all 20 selected checks.

The controller regression run against the original implementation produces five failures with passing controls. The fixed implementation passes. Resolver tests exercise macOS arm64, Windows x64, Linux x64/arm64 manifest selection, invalid redirects, missing assets, and recovery after network failure; these platform variants use mocked transport.

A separate background Electron 43.8.1 smoke on macOS arm64 uses the production resolver and real Electron networking against GitHub, resolving the ready `v1.4.241` tag. The controlled before/after reproduction also exercises the production resolver and actual GenericProvider. Neither proof exercises native installation.

All non-skipped GitHub CI checks pass for combined head `c04a6ca95604e064fb4f91adb1a57ea3dcf9adf0`: all five full unit shards, relay integration, Linux/Windows package checks, macOS updater regression tests, static analysis/typechecks, and the required aggregate check. Final independent review recommends merging that exact head as low risk with no code blockers.

## AI Disclosure

## Review

Independent sub-agent review found no actionable issues and rated the updater change low risk; 57 relevant tests passed independently. The prerequisite received two independent refactor audits, with identical moved runtime/test bodies and a merge-preservation gate reporting zero unexplained deletions and zero unrelated files. The five typed mock changes produce identical JavaScript. Also self-reviewed the feed-selection paths, timeout ownership, transport cleanup, and release-channel filtering. The added lookup runs only on the existing fallback path, uses HEAD for redirect discovery, retains five-second request deadlines, and reuses manifest/asset probes. No new polling, subprocess, persistent cache, or per-workspace work is introduced. Native Windows/Linux networking and installer execution were not exercised locally.

Review disposition for [the DMG-only manifest comment](#34076 (comment)): an independent executable comparison of the original and fixed implementations returned the same `ready` Atom result for a DMG-only manifest; the old fallback already handed that manifest directly to MacUpdater, which cannot select its required ZIP. This is an existing release-integrity limitation, not introduced or worsened by tag pinning. It remains outside this race fix; a complete integrity change must validate the native files list and architecture selection rather than merely finding any ZIP-like name.

## Agent skill upstream boundary

- [x] Not applicable; no upstream skill source or fixtures copied.

## Notes

Desktop updater implementation is shared with headless serve. No IPC/RPC contract, remote version requirement, mobile client code, filesystem path, or workspace-kind assumption changes. Existing RC/perf selection remains in place. If fallback discovery also fails, checks use the existing retry/error flow instead of launching a moving feed.

## Checklist

- [x] This PR is focused on consistent release selection
- [x] Problem, behavior, and mechanism explained
- [x] Visual proof N/A with network verification recorded
- [x] Self-reviewed for correctness, security, and performance
- [x] Cross-platform, remote, mobile, and folder-workspace impact considered
- [x] Required changed-code checks pass


Co-authored-by: Brennan Benson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reject expired updater feed selections

1 participant