Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): first pull request open no longer fails as interrupted #14122

Closedwhoisaldo(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/14122/headopened View on GitHub

Closes #14113.

The first time the PR panel opened after a turn, it often showed "Could not load pull requests — All fibers interrupted without error", and Retry fixed it. The client cancels its first detail read and immediately sends the same read again. When a cached read's last caller leaves, effect/Cache interrupts the lookup but keeps the entry until the lookup has stopped. The resent read lands in that window, joins the dying lookup, and gets its interrupt back as the answer.

As the triage suggests, the fix is in the cache read. getCached wraps Cache.get and asks once more when a read comes back with only an interrupt. By then the dying entry is gone, so the retry starts a fresh lookup. catchCauseIf does not run for a caller that was itself interrupted, so a real cancel still stops without spawning gh again. Every Cache.get in PullRequestService now goes through it. Detail, activity, preview, list, diff, stats, files-viewed, and viewer reads all share this shape, and the macOS reproduction on the issue saw activity fail too.

Evidence

  • getCached.test.ts reproduces the race from the issue. With plain Cache.get, the second read fails with a bare interrupt; with getCached it gets a fresh value. A second test checks that an interrupted read does not start another lookup.
  • The PullRequestService and PullRequestReadCache tests pass. Server tsc --noEmit, lint, and format are clean.
  • In-app: the reporter verified this branch with the reproduction from #14113, on Windows 11 with WSL2. Before, the first open failed 4/4; on this branch it loaded 4/4. The WebSocket trace shows the client still interrupting and resending detail, but the resent read no longer fails. Removing the retry made the race test fail again.
  • Not rerun on this branch: the reporter's unmodified macOS reproduction (16/16 failures before).

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when loading pull request lists, details, previews, activity, diffs, viewed files, and statistics. Requests are now more likely to complete successfully after an interrupted lookup, while other errors continue to behave as before.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at befe47c

      Macroscope's review found this PR approvable — This is a focused server bug fix that retries only interrupt-only cache failures across existing pull-request read paths, while preserving ordinary errors and caller cancellation. It adds targeted race-condition tests and does not alter schemas, defaults, deployment, or static-analysis configuration.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Important

      Review skipped

      We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

      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: pingdotgg/t3code/.coderabbit.yaml

      Review profile: CHILL

      Plan: Advanced

      Run ID: 7e5b5953-9746-48b0-8ff8-b4517ea8c032

      📥 Commits

      Reviewing files that changed from the base of the PR and between d15210cd3da79f9a1a495a6309d912d76362a046 and 4d4b7c81b45e1aa04179134feb506e5801942a36.

      📒 Files selected for processing (3)
      • apps/server/src/pullRequest/PullRequestService.ts
      • apps/server/src/utils/getCached.test.ts
      • apps/server/src/utils/getCached.ts

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


      📝 Walkthrough

      Walkthrough

      The change adds getCached, which retries a cache read once after an interrupt-only failure. Pull request service cache reads now use this helper. Their cache keys, TTLs, invalidation behavior, and surrounding read logic remain unchanged.

      Changes

      Cache Read Recovery

      Layer / File(s)Summary
      Interrupt-only cache retry
      apps/server/src/utils/getCached.ts, apps/server/src/utils/getCached.test.ts
      getCached retries Cache.get once for the same key when the failure contains only interrupts. Tests cover a concurrent read during interrupted lookup cleanup and confirm an interrupted caller does not start another lookup.
      Pull request cache reads
      apps/server/src/pullRequest/PullRequestService.ts
      Viewer, list, detail, preview, activity, diff, viewed-files, and list-stat reads use getCached instead of direct Cache.get calls.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Merge Risk: ⚪ Minimal · up to 4d4b7

      No actionable merge-blocking risk is identified; the change is mergeable after normal checks.

      Security Architecture Review

      Security architecture risk: 🟡 Moderate · up to 4d4b7

      A rare cancellation race may let a background viewer lookup run after its provider has entered a rate-limit pause. The retry is bounded, but it can weaken a control intended to prevent further background requests during that pause.

      Retained concerns

      • Medium · security · inferred: A background viewer read that passed its initial rate-limit check can retry an abandoned cache lookup after the host enters a pause. The retry does not repeat the background-read gate, and the shared viewer lookup permits paused provider calls.
      Security review details

      Security Blast Radius

      • inferred — The identified control gap is confined to background viewer lookups for a selected provider host, where an extra credentialed provider call may occur during a pause. The helper does not itself select a new host or credential.

      Security Findings and Attack Paths

      • inferred — Cancellation-driven lookup churn can put a background read into an abandoned viewer flight. If the host enters a pause before that read's recovery, its fresh lookup can pass through the allow-paused viewer wrapper. This timing-dependent path could consume provider capacity despite the background pause policy; it is not evidence of credential or privilege escalation.

      Trust Boundaries and Controls

      • observed — The provider wrapper still executes on a fresh lookup, but its viewer configuration passes allowPaused. The separate, non-bypass background check occurs only before the helper, not between its first and second cache reads.

      Resilience and Maintainability Implications

      • observed — Caller interruption remains terminal in the helper test, and recovery is limited to one additional read. These bounds limit work per invocation but do not restore the background pause check on that additional read.

      Hardening Proposals

      • proposed — Preserve the shared interactive viewer flight while rechecking the non-bypass pause policy before a background reader starts a recovery lookup.
      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Linked Issues check✅ PassedThe change addresses the server-side race in issue [#14113]. getCached retries one Cache.get when the result contains only interrupts. A caller interrupted during its own read does not start the r…
      Out of Scope Changes check✅ PassedThe changes stay within issue [#14113]. The new helper, its focused tests, and the replacement of pull-request cache reads support the interrupt-race fix. No unrelated product behavior is changed.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
      Title check✅ PassedThe title clearly identifies the server fix and the interrupted first-open pull request failure.
      Description check✅ PassedThe description explains the problem, root cause, implementation, issue reference, focused tests, manual verification, and unverified macOS reproduction. It provides the required information despite n…
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.
    4. Verified at 4d4b7c8 with the in-app reproduction from #14113.

      In-app (isolated dev server, Windows 11 + WSL2): I used the setup that failed 4/4 before: 250 ms onInterrupt delay in the detailCache lookup, a completed turn, and a first open per PR in a fresh browser session. On this branch, 4/4 loaded (#13190, #12870, #11380, #8981). The race still happened every time. The WebSocket frames show the client interrupting the first detail and resending it about 40 ms later. The interrupted request still exits with Interrupt, but the resend never fails and the panel renders:

       9944ms → Request 17 pullRequests.detail
       9981ms → Interrupt 17
       9981ms → Request 19 pullRequests.detail
      10243ms ← Exit 17 Failure [Interrupt]   # the lookup being torn down
               (no failed Exit 19; the panel shows the PR)

      Tests:

      • getCached.test.ts and PullRequestService.test.ts pass (168 tests).
      • With the catchCauseIf retry removed, the race test fails, so it guards the fix.
      • The plain-Cache.get test from the issue still fails, as expected: the race is in effect/Cache, and this PR routes the PR reads around it.

      I haven't rerun the unmodified macOS reproduction (16/16 before) on this branch.

    5. @simonsteiner thank you for testing this!

    6. juliusmarminge added labelsmacroscope-review

    7. Note

      Written by claude-opus-5-5 on behalf of Maria

      Hi! We are cleaning up open PRs, and this one does not say which model or harness was used to create it. If this change is really important, we recommend rebuilding the PR with a newer model and noting the model and harness in the PR description.

    8. maria-rcks closed this

Sign in to join this conversation.