Fix: validate retry.afterStatusCodes is an array#868
Open
JSap0914 wants to merge 1 commit into
Open
Conversation
retry.methods and retry.statusCodes both validate that the provided value is an array, throwing a clear error at construction time when it is not. retry.afterStatusCodes was missing this same guard: passing a non-array (e.g. a single number) silently slipped through normalizeRetryOptions, and only surfaced as a confusing TypeError deep inside #calculateRetryDelay when .includes() was called on a non-array. Adds the missing validation to keep all three options consistent.
sholladay
requested changes
Jun 19, 2026
sholladay
left a comment
Collaborator
There was a problem hiding this comment.
If I'm not mistaken, this test would also pass on the main branch.
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.
Bug
retry.methodsandretry.statusCodesboth validate that the provided value is an array at construction time, throwing a descriptive error immediately.retry.afterStatusCodeswas missing this same guard.Passing a non-array (e.g. a single status code number) silently passes through
normalizeRetryOptionsand only fails later inside#calculateRetryDelayas a confusing:This error appears during a retry attempt — well after construction — making it hard to diagnose.
Fix
Add the missing validation to
normalizeRetryOptionsso all three array options are consistent:Verification
Result: 1 test passed (new test). Full
npx ava test/retry.ts: 85 tests passed, 0 failed.