Skip to content

Stop retrying 4xx and honor caller AbortSignal in resilient-fetcher - #9

Draft
arnelirobles wants to merge 2 commits into
mainfrom
fix/3-no-4xx-retry
Draft

arnelirobles wants to merge 2 commits into
mainfrom
fix/3-no-4xx-retry

Conversation

@arnelirobles

@arnelirobles arnelirobles commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

A non-ok response that retryOn rejects (4xx by default) now propagates as an error instead of being caught and retried by the catch block. The catch only consults retryOn for transport and timeout errors. A caller-supplied AbortSignal now aborts the request and is never retried, no attempt starts after the abort, and its listener is removed when each attempt finishes.

Closes #3

- test: packages/resilient-fetcher/src/index.test.ts "does not retry on 4xx by default"
  breaks: packages/resilient-fetcher/src/index.ts "if (error instanceof HttpStatusError) {"
- test: packages/resilient-fetcher/src/index.test.ts "does not retry on 4xx by default"
  breaks: packages/resilient-fetcher/src/index.ts "throw new HttpStatusError(response.status);"
- test: packages/resilient-fetcher/src/index.test.ts "already aborted caller signal makes no fetch call"
  breaks: packages/resilient-fetcher/src/index.ts "throw callerSignal.reason ?? new DOMException("
- test: packages/resilient-fetcher/src/index.test.ts "caller abort stops the request and is not retried"
  breaks: packages/resilient-fetcher/src/index.ts "if (callerSignal?.aborted) {"
- untested: packages/resilient-fetcher/src/index.ts #1
  why: listener removal in the finally block has no observable effect in a mocked fetch test

@coderabbitai

coderabbitai Bot commented Nov 12, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resilient-fetcher retries every 4xx despite documenting 5xx only, and the guard test is skipped

1 participant