Skip to content

fix(swr): preserve explicit writes during refresh (LAB-751) - #84

Merged
27Bslash6 merged 2 commits into
mainfrom
fix/LAB-751-swr-refresh-race
Jul 26, 2026
Merged

fix(swr): preserve explicit writes during refresh (LAB-751)#84
27Bslash6 merged 2 commits into
mainfrom
fix/LAB-751-swr-refresh-race

Conversation

@27Bslash6

@27Bslash6 27Bslash6 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Fixes the post-merge review findings from LAB-751.

SWR refreshes now persist to L2 without mutating L1; completeRefresh is the only L1 writer and retains its version-token guard, so concurrent explicit writes win. The change also avoids taking markers for null values, removes the redundant manager-level tracker that could leak on torn-down Workers isolates, and removes the internal WaitUntil re-export.

Validation:

  • focused SWR unit tests (46 passing)
  • real workerd SWR lane (5 passing)
  • TypeScript type-check
  • ESLint and Prettier

Docs: no update needed; this corrects internal refresh lifecycle behavior without changing the documented Workers API or SWR contract.

Co-authored-by: multica-agent <github@multica.ai>
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 56 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1bdca7e5-c063-430e-be00-61a988346681

📥 Commits

Reviewing files that changed from the base of the PR and between 08fd853 and 9fd99f1.

📒 Files selected for processing (7)
  • packages/cachekit/src/cache-core.ts
  • packages/cachekit/src/cache.test.ts
  • packages/cachekit/src/cache/background-refresh.test.ts
  • packages/cachekit/src/cache/background-refresh.ts
  • packages/cachekit/src/l1/lru-cache.test.ts
  • packages/cachekit/src/l1/lru-cache.ts
  • packages/cachekit/test/workers/swr.workers.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/LAB-751-swr-refresh-race

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

@27Bslash6
27Bslash6 marked this pull request as ready for review July 25, 2026 11:50
@kodus-27b

This comment has been minimized.

Comment thread packages/cachekit/src/cache-core.ts
Comment thread packages/cachekit/src/workers/index.ts Outdated
…sion tests (LAB-751)

Kody review round on #84:

- Restore the WaitUntil type export on the /workers entry (and its
  cache-core re-export). It shipped in the published cachekit v0.1.4 —
  removing it as 'internal' was a breaking API change hiding in a fix PR.
- Add the unit-level regression tests for the updateL1=false refresh path:
  a happy-path test proving completeRefresh is what lands the refreshed
  value in L1 (with L2 persistence verified through an L1-less reader),
  and a gated-backend interleaving test proving an explicit set() during
  an in-flight refresh wins in L1. The second test was verified to FAIL
  against the pre-#84 behavior (refresh clobbers L1 with the stale value).
- Reword the setEntry L1 comment the review panel flagged as overclaiming:
  the version guard is authoritative for L1 only; the refresh's backend
  write remains last-write-wins in L2 (conditional writes would need CAS
  the Backend contract doesn't have).

Co-authored-by: multica-agent <github@multica.ai>
@kodus-27b

kodus-27b Bot commented Jul 25, 2026

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@27Bslash6

Copy link
Copy Markdown
Contributor Author

@kody start-review

@27Bslash6
27Bslash6 enabled auto-merge (squash) July 25, 2026 14:27
@27Bslash6
27Bslash6 merged commit c4d4aed into main Jul 26, 2026
12 checks passed
@27Bslash6
27Bslash6 deleted the fix/LAB-751-swr-refresh-race branch July 26, 2026 01:33
This was referenced Jul 26, 2026
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.

1 participant