fix(elixir-client): Add fast-loop detection#4028
Conversation
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
|
@/tmp/review_body.txt |
a7c037e to
0ee52aa
Compare
|
Claude Code Review Summary This PR ports the TypeScript client's fast-loop detection to the Elixir client. When a server or CDN bug causes repeated non-progressive responses at the same offset, the client now detects the stuck retry loop, clears caches on first detection, applies exponential backoff on subsequent ones, and raises an error after 5 consecutive detections. The implementation is clean and well-tested. What's Working Well
Issues Found Critical (Must Fix): None. Important (Should Fix): None. Suggestions (Nice to Have):
The integration test starts an Agent with Agent.start_link/1. Project convention is to use start_link_supervised!/1 so ExUnit's supervisor handles cleanup on test failure. While the Agent is linked to the test process and will be cleaned up on normal exit, start_link_supervised!/1 is more robust.
The {:stale_retry, ...} path calls fetch/1 recursively, so stale-retry requests are also counted in the sliding window and can trigger fast-loop detection. This is arguably correct behaviour (repeated stale 409s at the same offset are a CDN loop), but a brief comment near the stale_retry handler would make this interaction explicit for future readers.
Several tests build lists of identical entries via Enum.map(0..3, fn _ -> ... end). List.duplicate(entry, 4) is slightly more expressive of intent, but this is purely stylistic. Issue Conformance No linked issue was attached to this PR. The PR description clearly explains the change and references the TypeScript client's matching behaviour, which provides sufficient context. Ideally a GitHub issue would be created to track the underlying bug (undetected fast retry loops) and linked here. Previous Review Status This is the first review iteration. Review iteration: 1 | 2026-03-19 |
When a server or CDN bug causes repeated responses at the same offset without progress, the client would hammer the server indefinitely. Port the TypeScript client's fast-loop detection: track non-live requests in a 500ms sliding window, and if 5+ requests occur at the same offset, clear caches on first detection, apply exponential backoff on subsequent detections, and raise an error after 5 consecutive detections.
0ee52aa to
8ec8965
Compare
|
This PR has been released! 🚀 The following packages include changes from this PR:
Thanks for contributing to Electric! |
When a server or CDN bug causes repeated responses at the same offset without progress, the client would hammer the server indefinitely. Port the TypeScript client's fast-loop detection: track non-live requests in a 500ms sliding window, and if 5+ requests occur at the same offset, clear caches on first detection, apply exponential backoff on subsequent detections, and raise an error after 5 consecutive detections.