zkat/make-fetch-happen

notify on retries

zkat opened this issue · 1 comments

zkat commented

we already inform users about how many retries it took to complete a request. It might be nice to accept a callback for synchronous notifications whenever a retry happens, so users can be modified.

This should not expose any internal datastructures or allow any changes to the retry logic. If users want to control retry, they should use existing settings.

zkat commented

Implementation note: I think this can be implemented by wrapping the retry handler here: https://github.com/zkat/make-fetch-happen/blob/latest/index.js#L312

There should be an option, opts.onRetry, that will be called, if present, with the error as the argument. The return value should not be used at all, and the retryHandler itself should not be exposed to it. retryHandler should be called by the wrapper right after onRetry completes.