tim-kos / node-retry

Abstraction for exponential and custom retry strategies for failed operations.
Other
1.22k stars 80 forks source link

Include previous error even if there's a timeout #70

Closed cdeevfrr closed 3 years ago

cdeevfrr commented 5 years ago

Why (this section hopefully won't change)

We are using the async-retry library, which seems to make a new retryOperation object, call attempt on it, and then call retry on it if needed. If it passes in an error to retry, it seems to rely on node-retry to add the error to the list of errors that's being kept.

However, when there is a timeout, the error passed in is dropped. In practice, this means that when something throws one error and then times out, the one error is never added to retryOperation._errors, so our code (which eventually receives operation.mainError()) gets the error message "RetryOperation timeout occurred".

What (this section hopefully won't change)

It would be nice if the error passed in to retry always made its way into the _errors array, so this wouldn't happen.

How (open to change)

We can copy line 53 and paste just above line 49. I would have made a PR but I couldn't figure out how to do it on this repo.