Skip to content

retry-handler should pass any error to retry method #4244

@fatal10110

Description

@fatal10110

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)
  }
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions