fix(retry): make retry delay responsive to abort signal#18
Open
itxaiohanglover wants to merge 1 commit into
Open
fix(retry): make retry delay responsive to abort signal#18itxaiohanglover wants to merge 1 commit into
itxaiohanglover wants to merge 1 commit into
Conversation
The withRetry function only checked abortSignal at the start of each retry attempt. During the retry delay (up to 30s with default config), the abort signal was ignored, causing abort to not take effect until the next attempt cycle. Fix: use setTimeout + abort event listener so the delay promise rejects immediately when the signal fires.
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.
Problem
The
withRetryfunction insrc/utils/retry.tsonly checkedabortSignalat the start of each retry attempt. During the retry delay (up to 30 seconds with default config), the abort signal was completely ignored.This means if a user calls
abort()during a retry delay, the function continues waiting for the full delay before checking the signal on the next iteration. For a 30-second delay, this makes the abort effectively useless.What changed
Replaced the plain
setTimeoutdelay with an abortable promise that listens for the abort event:Validation
tsc— compiles without errors (no type changes)abortSignalis providedabortSignalis provided and fires during delay, the promise rejects immediately withError('Aborted')instead of waiting