fix(server): return fresh live pull request reads - #6472
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
There was a problem hiding this comment.
One finding: an invariant comment was deleted from code that this PR keeps. Everything else (namespace imports, Foo["Service"] usage, service/layer shape, error handling) is unchanged and conventional.
Posted via Macroscope — Effect Service Conventions
ApprovabilityVerdict: Needs human review This PR removes stale-while-revalidate caching for multiple PR service endpoints (list, detail, activity, listStats), changing user-facing latency behavior. Users will now wait for fresh network requests rather than receiving cached responses. This architectural change to caching strategy warrants human review. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Expired list, detail, activity, and line-stat cache reads now wait for and return the newly fetched host value. Diff reads retain stale-while-revalidate because they are expensive, are not live-polled, and already bypass held values after explicit refreshes and mutations.
Why
The previous stale-while-revalidate wrapper returned the old value to each live poll and updated only the server cache in the background. The client did not receive that background result, leaving automatic refresh one cycle behind and potentially stale indefinitely after returning to a tab. Narrowing the change to live-polled mutable reads fixes freshness without putting diff loading back on the interaction critical path.
Validation
vp test run apps/server/src/pullRequest/PullRequestService.test.ts(87 tests passed)vp run --filter t3 typecheckChecklist
Generated with GPT-5.6 in the Codex harness.
Note
Medium Risk
Changes caching semantics for frequently polled reads—callers may wait on host/CLI after TTL expiry instead of instant stale responses, which fixes freshness but increases latency on those paths.
Overview
Live-polled pull request reads (
list,detail,activity,listStats) no longer use stale-while-revalidate. After the Effect cache TTL expires, the next read blocks on a fresh host fetch and returns that result instead of immediately serving an old value while refreshing in the background.diffstill uses stale-while-revalidate via a dedicatedstaleDiffhelper (the genericstaleWhileRevalidateandLIST_STALE_WINDOW/DETAIL_STALE_WINDOWare removed). Epoch-basedinvalidatebehavior is unchanged.A regression test advances
TestClockpast the 30s list TTL and asserts the secondlistcall hits the host again and returns the updated payload.Reviewed by Cursor Bugbot for commit 99b64ec. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Return fresh data on first read after cache expiry for pull request list, detail, activity, and stats
Previously,
PullRequestServiceused stale-while-revalidate for list, detail, activity, and listStats caches, serving stale data on the first read after TTL expiry while refreshing in the background. These methods now callCache.get(...)directly, so the first read after expiry blocks on a fresh fetch and returns up-to-date data.staleDiffclosure that refreshes in the background withinDIFF_STALE_WINDOW.Macroscope summarized 99b64ec.