onRetryAttempt is not awaited / custom back off strategy
Even though in the documentation it's stated that onRetryAttempt can return a promise, the promise is not awaited: see https://github.com/googleapis/gaxios/blob/bf6afebe9bb50261d0aed5ae128853f977682773/src/common.ts#L147 and https://github.com/googleapis/gaxios/blob/bf6afebe9bb50261d0aed5ae128853f977682773/src/retry.ts#L79
My challenge is to build a custom retry handler, which checks for retry-after headers and so on.. I see that adding await would maybe change some behaviour for end-users.. so I would instead vote for a property that allows to override the default expoenitial back off handler? Would that be an option? I can prepare a PR in this case.
Bascially it would be just here: https://github.com/googleapis/gaxios/blob/bf6afebe9bb50261d0aed5ae128853f977682773/src/retry.ts#L73
to chagne this line to:
const backoff = config.backoffHandler && config.backoffHandler(err) || new Promise(resolve => {
setTimeout(resolve, delay);
});
and backoffHandler is an optional function that returns a Promise
@simllll thank you for the bug report.
@simllll would this allow for utilizing an exponential backoff retry strategy?
Yes, in this case you can do whatever you want to do... Including exponential back off
@simllll switched to feature request from bug, since this is requesting an addition to functionality.
Would you be interested in submitting a patch for this functionality?