Skip to content

fix(elixir-client): Sync CDN-resilience fixes from the TypeScript client#4231

Merged
magnetised merged 3 commits intomainfrom
magnetised/elixir-client-sync-20260429
Apr 29, 2026
Merged

fix(elixir-client): Sync CDN-resilience fixes from the TypeScript client#4231
magnetised merged 3 commits intomainfrom
magnetised/elixir-client-sync-20260429

Conversation

@magnetised
Copy link
Copy Markdown
Contributor

The TS client has three behaviours around 409 (must-refetch) handling that the Elixir client was missing. All three protect against misbehaving proxies/CDNs that strip query params, cache 409s, or omit response bodies.

Changes

  1. Cache-buster on every 409 — adds a fresh cache-buster query param after every must-refetch response, so a CDN that ignores expired_handle in its cache key can't pin us to a stale 409. (poll.ex handle_must_refetch/4)
  2. Self-heal stuck expired_handle cache — when stale retries are exhausted, clear the cached expired handle and retry once without it before raising. Recovers from the case where a stale expired_handle value itself is what's poisoning the
    CDN cache slot. (expired_shapes_cache.ex clear_handle/1, poll.ex handle_stale_response/2, shape_state.ex self_heal_attempted? flag)
  3. Synthetic must-refetch control message — always emit a must_refetch message on 409, regardless of body content, so subscribers reliably get the signal to clear local state even when a proxy strips the body.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 65.26%. Comparing base (119731e) to head (d34dd37).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/elixir-client/lib/electric/client/poll.ex 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4231      +/-   ##
==========================================
+ Coverage   64.31%   65.26%   +0.94%     
==========================================
  Files         143      170      +27     
  Lines       19092    20232    +1140     
  Branches     4679     4713      +34     
==========================================
+ Hits        12279    13204     +925     
- Misses       6810     7025     +215     
  Partials        3        3              
Flag Coverage Δ
elixir 78.84% <92.85%> (?)
elixir-client 78.84% <92.85%> (?)
packages/agents 53.73% <ø> (ø)
packages/agents-runtime 78.61% <ø> (+0.12%) ⬆️
packages/agents-server 66.25% <ø> (+0.21%) ⬆️
packages/agents-server-ui 0.00% <ø> (ø)
packages/electric-ax 33.44% <ø> (+3.33%) ⬆️
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/start 82.83% <ø> (ø)
packages/typescript-client 94.36% <ø> (+0.05%) ⬆️
packages/y-electric 56.05% <ø> (ø)
typescript 64.52% <ø> (+0.21%) ⬆️
unit-tests 65.26% <92.85%> (+0.94%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@magnetised magnetised changed the title fix(elixir-client): Sync three CDN-resilience fixes from the TypeScript client fix(elixir-client): Sync CDN-resilience fixes from the TypeScript client Apr 29, 2026
Copy link
Copy Markdown
Contributor

@robacourt robacourt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@magnetised magnetised force-pushed the magnetised/elixir-client-sync-20260429 branch from 3d10c72 to d34dd37 Compare April 29, 2026 13:36
@magnetised magnetised merged commit a56be3e into main Apr 29, 2026
56 of 57 checks passed
@magnetised magnetised deleted the magnetised/elixir-client-sync-20260429 branch April 29, 2026 13:44
@github-actions
Copy link
Copy Markdown
Contributor

This PR has been released! 🚀

The following packages include changes from this PR:

  • @core/elixir-client@0.10.1

Thanks for contributing to Electric!

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