Skip to content

[BY-3620]: Make retry work with Node's fetch, and only retry safe requests - #48

Merged
paulambanks merged 2 commits into
masterfrom
feature/by-3620
Sep 30, 2026
Merged

paulambanks merged 2 commits into
masterfrom
feature/by-3620

Conversation

@paulambanks

Copy link
Copy Markdown
Contributor

Before

  • Retry was off by default, and no Beyonk app enabled it.
  • If enabled, it only matched e.code. Node's fetch reports network errors as TypeError: fetch failed with the code on e.cause, so retries never happened.
  • If it had matched, it would have retried any method, including writes.

After

  • It matches the code on the error or on its cause, so resets (ECONNRESET) from Node's fetch are now retried.
  • Only GET, HEAD and OPTIONS are retried by default, so a write that may have reached the server is never sent twice. Endpoints that are safe to repeat can opt in with the new methods option.
  • It's still off by default. Nothing changes for an app until it sets retry.

Impact: no existing app changes behaviour. Apps that enable retry: { attempts: 2, errors: ['ECONNRESET'] } get one automatic retry on reset GET requests.

@paulambanks paulambanks self-assigned this Sep 30, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@beyonk/http@48

commit: a813f40

@alexdilley alexdilley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't tell if we want to actually retry on ECONNRESET as a library default or not.

Comment thread lib/index.js
Comment thread lib/index.js Outdated
Comment thread lib/types.ts Outdated
Comment thread lib/index.js Outdated
@paulambanks
paulambanks force-pushed the feature/by-3620 branch 2 times, most recently from 76c5b15 to 6d53d47 Compare September 30, 2026 12:43
Comment thread lib/index.js Outdated
Comment thread lib/index.js Outdated
@paulambanks
paulambanks force-pushed the feature/by-3620 branch 2 times, most recently from aa187f9 to 7b37fb7 Compare September 30, 2026 13:17
@paulambanks
paulambanks merged commit 819bed9 into master Sep 30, 2026
3 checks passed
@paulambanks
paulambanks deleted the feature/by-3620 branch September 30, 2026 13:29
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.

2 participants