Skip to content

Retry forever instead of hanging on retries: Infinity - #98

Open
tim-kos wants to merge 3 commits into
masterfrom
retries-infinity
Open

tim-kos wants to merge 3 commits into
masterfrom
retries-infinity

Conversation

@tim-kos

@tim-kos tim-kos commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

retries: Infinity is meant to retry forever: retry.operation() already treats it like forever: true. But retry.timeouts() first tries to build an endless array of timeouts, so the process hangs until V8 aborts with "invalid size error". p-retry users hit this too.

retry.timeouts() now builds a finite backoff for retries: Infinity instead:

  • With a finite maxTimeout, the timeouts grow until they reach maxTimeout, capped at 1000 timeouts. { factor: 1.1, maxTimeout: 60000 } ramps up to 60000 instead of stalling partway.
  • Without one, it returns the timeouts for the default 10 retries.
  • With factor <= 1 the timeouts never grow, so a single timeout is enough.

retry.operation() and retry.wrap() then keep repeating the last timeout, like forever: true does. Calling retry.timeouts({ retries: Infinity }) directly returns that finite list instead of hanging. It can't carry the "forever" flag, so the README documents the forever behavior under retry.operation().

Unlike #77, this doesn't mutate the caller's options, and it keeps retries: 0 and other falsy values.

Fixes #84
Supersedes #77

🤖 Generated with Claude Code

tim-kos and others added 3 commits October 19, 2026 17:21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Check for infinity value in retries

1 participant