Hold replay batches until Retry-After has passed - #55
Merged
Merged
Conversation
ColtenOuO
force-pushed
the
fix/replay-honor-retry-after
branch
from
September 17, 2026 05:04
33a77ad to
90e8638
Compare
jserv
reviewed
Sep 17, 2026
jserv
reviewed
Sep 17, 2026
After a 429 the replay feed put the batch back and recorded when the server's window closed, then scheduled the next flush a fixed second later, and sendQueuedBatch never looked at the window. The browser asked again every second until it passed. Flushes inside the window now reschedule to its end instead of posting.
ColtenOuO
force-pushed
the
fix/replay-honor-retry-after
branch
from
September 17, 2026 09:48
90e8638 to
0779fbd
Compare
Contributor
|
Thank @ColtenOuO for contributing! |
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.
Summary
After a 429, the replay feed put the refused batch back at the front of the queue and recorded when the server's rate-limit window closes, but nothing read that value. The next flush was still scheduled a fixed second later, and
sendQueuedBatchposted without checking the window, so aRetry-After: 30was answered with a new request every second until the window passed.Changes
scheduleFlush(), which waits for whichever is later: the usual one second or the end of the rate-limit window. Both fixed one-secondsetTimeoutcalls now go through it.sendQueuedBatchno longer posts while the window is open; it reschedules the flush for the window's end.tests/browser/replay-feed.test.js, which runs the feed against mocked timers andfetch. After a 429 withRetry-After: 30, nothing is posted for the next 29 seconds, and at 30 seconds the kept batch goes out together with the event queued behind it.Summary by cubic
Holds replay batches until the server's Retry-After window has passed. Previously, after a 429 the feed scheduled the next flush a fixed second later and posted without checking the recorded window, so a
Retry-After: 30drew new requests every second.Bug Fixes
scheduleFlush(), which waits for the later of the usual one second or the end of the rate-limit window; both fixed one-second timers now use it.sendQueuedBatchno longer posts while the window is open and reschedules the flush for the window's end.tests/browser/replay-feed.test.js, which mocks timers andfetchto verify nothing posts for 29 seconds after a 429 and the kept batch goes out with the queued event at second 30.Written for commit 0779fbd. Summary will update on new commits.