Prevent caching handle-less 409 must-refetch responses#4638
Open
KyleAMathews wants to merge 2 commits into
Open
Prevent caching handle-less 409 must-refetch responses#4638KyleAMathews wants to merge 2 commits into
KyleAMathews wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4638 +/- ##
==========================================
- Coverage 59.46% 59.45% -0.01%
==========================================
Files 385 385
Lines 43039 43039
Branches 12383 12380 -3
==========================================
- Hits 25591 25588 -3
- Misses 17371 17375 +4
+ Partials 77 76 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sjdonado
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Handle-less
409 must-refetchresponses are no longer cacheable; only409s with anelectric-handlekeep the short-lived redirect cache behavior. This prevents shared caches from replaying a non-actionable409that gives clients no replacement handle to follow.Root Cause
409 must-refetchresponses serve two subtly different roles:electric-handle, the response acts like a shape redirect and can safely be cached briefly to coalesce refetch storms.electric-handle, the response only tells the client to renegotiate from scratch. Caching that response can replay a stale, non-actionable retry signal and keep clients from converging on a fresh shape handle.The previous cache-header logic cached both cases, using
max-age=1for handle-less409s.Approach
The sync service now only special-cases
409responses when they include a handle:Handle-less
409s fall through to the existing genericstatus >= 400handling, which sets bothcache-control: no-storeandsurrogate-control: no-store.Key Invariants
409responses withelectric-handleremain cacheable as redirect/coalescing responses.409responses withoutelectric-handleare not stored by downstream or surrogate caches.must-refetchcontrol message in both cases.Non-goals
Trade-offs
This gives up the previous 1-second cache coalescing for handle-less
409s. That is preferable because a handle-less409is not a useful redirect target; caching it can amplify the stuck-loop failure mode described in the bug report.Verification
Also verified the changeset coverage:
Files changed
packages/sync-service/lib/electric/shapes/api/response.ex— restrict cacheable409handling to responses with a shape handle, allowing handle-less409s to use the genericno-storeerror path.packages/sync-service/test/electric/plug/serve_shape_plug_test.exs— assert handle-less shape-rotation409s have no handle and are markedno-store..changeset/handleless-409-no-store.md— add patch changeset for@core/sync-service.