nodejs / nodejs/undici

retry-handler should pass any error to retry method

Open
#4,244 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
7.7k
Forks
880
Avg merge
2d 16h
Merged PRs (30d)
68

Description

if we pass AbortSignal with timeout, to limit the request time, in case of a timeout, the controller will be aborted in this case, retry handler assumes there is no reason to retry the request.

I want to move the decision to the user, the user may decide to mutate the "opts", pass new AbortSignal, and retry the request.

The implementation should look like...

Need to change

if (controller?.aborted || isDisturbed(this.opts.body)) {
  this.handler.onResponseError?.(controller, err)
  return
}

to

if (isDisturbed(this.opts.body)) {
  this.handler.onResponseError?.(controller, err)
  return
}

then use can do

new RetryAgent(new Agent(), {
  retry: (err, { state, opts }, cb) => {
    if (err.code === DOMException.TIMEOUT_ERR)
       opts.signal = AbortSignal.timeout(...)
       cb()
       return
    }
    
    cb(err)
  }
})

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the retry-handler condition that checks controller?.aborted and isDisturbed(this.opts.body), then read how RetryAgent invokes the retry callback. Done means errors from an aborted controller reach the user retry method unless the request body is disturbed, allowing the callback to replace opts.signal and retry.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.