Skip to content

Pass the attempt to every operation timeout callback - #99

Open
tim-kos wants to merge 2 commits into
masterfrom
operation-timeout-attempt
Open

tim-kos wants to merge 2 commits into
masterfrom
operation-timeout-attempt

Conversation

@tim-kos

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

Copy link
Copy Markdown
Owner

Fixes the inconsistencies reported in #82:

  • Operation timeout callback: on the first attempt it was called without the attempt number, while later attempts got one. It now always gets the current attempt. The first attempt's timeout timer also ignored unref: true; it now honors it like the later ones do.
  • Forever delay: once a forever operation used up its timeouts, it passed [lastTimeout] (a one-element array) to setTimeout. That only worked because Node coerces the array to a number. It now passes the number.
  • README:
    • It said forever restarts from the first timeout, but the operation keeps repeating the last one, which is what the code has always done. The docs now say so.
    • They now say the timeout callback receives the attempt number.
    • They document the forever option that retry.timeouts() reads, which was undocumented.

Behavior change worth a changelog line: a timeout callback that treats its first argument as an error (e.g. a Node-style (err) callback) used to get undefined on the first attempt and now gets 1. Later attempts already received the attempt number.

Each new test fails on master. They live in their own files, so this doesn't conflict with #98 or #100.

Fixes #82

🤖 Generated with Claude Code

…er timeout as a number

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…forever option

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.

Missing current attempt in callback

1 participant