Skip to content

Abort failed runtime downloads after cleanup - #26269

Merged
OrcaWin merged 5 commits into
mainfrom
nwparker/perf-runtime-download-failure-abort
Oct 8, 2026
Merged

OrcaWin merged 5 commits into
mainfrom
nwparker/perf-runtime-download-failure-abort

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​116 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​108
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

ELI5

A failed runtime download can leave its network request running after setup has returned an error and removed its temporary files. Failed downloads now abort their own request immediately, releasing the native connection.

What Changed

Each failed archive download attempt selects its existing error before aborting its internal controller, then throws that same error. Selecting first preserves the stall error and retry classification added on main. Existing body cancellation, file close and staging cleanup still run. Successful downloads keep their existing signal and cache behavior; retry counts and 1/3/9-second delays are unchanged.

Why

Canceling the response body alone does not reliably retire Electron's native request. Aborting the controller that already owns this download closes that ownership gap without changing deadlines, redirects, proxy settings, size limits or checksum verification.

The actual public archive materializer and desktop HTTP client were exercised through Electron 43.7.5 against an owned native HTTPS server on macOS. The final replay uses the actual updated retry implementation. One HTTP 503 submission makes four attempts with the real default retry delays. All four original native requests remained open 5.5 seconds after the materializer returned, including after GC; the fix leaves none. Separate oversized-declaration and real staging-open-collision cohorts each left three original requests versus zero after the fix. Each stalled response sent only 1 KiB. Temporary directories were removed in both versions, and all 16 paired result/error/file/cache/extraction controls matched, including HTTP 404 refusal and recovery from 503 to a verified archive.

This affects cold or missing verified runtimes during SSH/WSL setup; warm caches skip downloads. Existing callers have a three-minute external deadline, so the original requests can eventually retire. This measures prompt cleanup after failure, not a permanent leak or a cause for the intermittent Codex typing pause.

Linked Issue

Performance audit; no existing issue linked.

Visual Proof

N/A

This changes native request ownership after a failed download. Renderer and setup error behavior are unchanged. The public native before/after resource check is described above.

Testing

  • Original native resource proof exercised the public materializer with real desktop HTTP, an owned HTTPS server, disk staging/cache, hashes and archive extraction on macOS. Paired results, errors, request counts and cache ownership matched. That recorded proof was not repeated for this review update.
  • Fresh integrated validation passed 654 main/renderer tests, 83 mobile tests and 78 performance contracts, including the download ownership and materializer regressions.
  • Full normal project typechecks and desktop build passed; final changed-code quality gate reports zero new findings across 138 files.
  • The same test-only correction is included in [CI] Keep idle region test sessions past their initial grace period #26397: region-change scenarios advance beyond the initial grace period, renew the existing control lease and refresh heartbeats. Corrected transport suites pass 16 tests; 23 source-owned checks preserve the minimum-age guard.
  • Current main includes the runner package-source repair for the previous Linux setup timeout. Hosted checks must complete on this refreshed head; no all-green claim before they finish.

The original broader SSH run recorded one unrelated macOS shell-fixture assertion alongside 4,063 passing tests. It was not rerun during this update. Native resource proof was macOS; live Windows/Linux request cleanup was not repeated locally. The optional standalone E2E typecheck has the same existing diagnostics as pinned main, with no new semantic error.

Review

Independent review of the production proposal and native provenance found no blocker. The small production change reuses the existing request owner and preserves the current-main error selection before aborting. No remote wire, execution-host authority, polling or cache policy changes; failed downloads never cancel their caller's controller.

Agent skill upstream boundary

  • Not applicable.

Checklist

  • Small and focused.
  • Explained the user-facing change, mechanism and choice of approach.
  • Visual proof is N/A with the native validation reason above.
  • Self-reviewed for correctness, security and performance.
  • Cross-platform, folder and SSH behavior considered.
  • Relevant tests, typecheck, changed-code quality and fresh build pass; hosted CI will follow.

@nwparker
nwparker marked this pull request as draft October 7, 2026 17:15
@nwparker
nwparker marked this pull request as ready for review October 7, 2026 17:15
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 617fa192-4016-4278-8471-0496f45040f0
📥 Commits

Reviewing files that changed from the base of the PR and between ecf5467 and bf4a50e.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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: ea152458-5cd6-40e3-a3ee-b3ce45f268ef
📥 Commits

Reviewing files that changed from the base of the PR and between 469bb2f and ecf5467.

📒 Files selected for processing (1)
  • tests/e2e/relay-region-correction.unit.test.ts

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


📝 Walkthrough

Walkthrough

When an error occurs during archive download, writing, or checksum verification, downloadVerifiedArchiveOnce selects the error to propagate before aborting its stall controller. A stall produces the stalled error unless the caller’s signal was aborted. Tests check request-signal states during retries and failures, error propagation, response cancellation, caller-signal handling, and staging cleanup. Cache tests verify that successful fetch attempts use signals that remain active.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to ecf54

A failed download can still delay request retirement and staging cleanup if stream cancellation waits on the request, though the delay is bounded by the stall timeout. Merging carries limited risk; aborting before awaiting cancellation would make cleanup prompt.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: aborting failed runtime download requests after cleanup.
Description check ✅ Passed The description is detailed and covers the user impact, implementation, rationale, testing, compatibility considerations, review status, and checklist. It documents that no issue is linked, which is a…
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch nwparker/perf-runtime-download-failure-abort
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4d0d06d7-78d5-418e-a917-e625dfdde105
📥 Commits

Reviewing files that changed from the base of the PR and between 7d6d7ca and aaf01ba.

📒 Files selected for processing (2)
  • src/main/ssh/pinned-runtime-materializer-node.test.ts
  • src/main/ssh/runtime-archive-download.ts

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

)
}
} catch (error) {
stall.abort()

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Abort the request before awaiting stream cancellation.

On an HTTP error, oversized response, or staging-open failure, this code awaits stream cancellation before it reaches stall.abort(). If cancellation waits for the request signal, the request and staging cleanup remain pending until the 120-second stall timer aborts the signal. Web Streams permits asynchronous cancellation. (nodejs.org) Abort the owned controller when the failure is known, before awaiting cancellation. Preserve the original error when cancellation rejects.

@nwparker
nwparker force-pushed the nwparker/perf-runtime-download-failure-abort branch from aaf01ba to 14f174e Compare October 7, 2026 17:44
@OrcaWin
OrcaWin merged commit e862394 into main Oct 8, 2026
64 checks passed
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.

2 participants