feat: Add Exponential Backoff With Jitter on Retry - #17
Merged
Conversation
Nack and handler throw wait min(cap, base * 2^(attempt-1)) before redelivery, with full/equal/decorrelated jitter so retries do not align. A delayed retry list keeps other ready work moving.
Omitted retryBackoff now has a nack-and-wait test so the constructor default cannot flip silently. README usage nacks, advances ManualClock, then shows redelivery. Decorrelated lastDelayMs is spelled out and covered at the queue.
ThomasHartDev
force-pushed
the
thomas/feat/retry-backoff
branch
from
September 4, 2026 20:32
2424870 to
3f1c456
Compare
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.
Work-queue nack used to requeue immediately, and the pump could hand the same payload back in the same tick. That is a retry storm: every failing consumer wakes together and hammers a dependency that is already unhappy.
A nack or handler throw now waits before redelivery. For none, full, and equal jitter the wait is min(cap, base * 2^(attempt-1)), then jitter (full by default). Decorrelated ignores attempt and walks lastDelayMs: the next delay is drawn between base and min(cap, last * 3). Other ready work still goes out while a retry sits on the delayed list. Pass retryBackoff: false when you want the old immediate requeue. Tests drive this with ManualClock so we do not sleep.
The package barrel also re-exports DeadLetterQueue so existing tests that import those names from src/index keep typechecking.
Closes #16.