adobe / adobe/node-fetch-retry

confusing error message 'network timeout' if retryMaxDuration is hit

Open
#81 0 comments 0 reactions 1 assignee Claimed by @alexkli View on GitHub
enhancement
Dominant language
JavaScript
Stars
44
Forks
16
PR merge metrics
No merged PRs in 30d

Description

## Observed behavior

If `retryMaxDuration` is reached, you get this error thrown ([code here](https://github.com/adobe/node-fetch-retry/blob/3e512e5a6a892e0bd51c862d8fd1abdbdf1b4c57/index.js#L245)):

```
FetchError: network timeout at https://example.com/some/url
at wrappedFetch (/some/filesystem/folder/myproject/node_modules/@adobe/node-fetch-retry/index.js:245:20)
at runMicrotasks ()
at runNextTicks (node:internal/process/task_queues:61:5)
at processTimers (node:internal/timers:497:9) {
type: 'request-timeout'
}
```

This is confusing, because:

1. it's not directly a network timeout
2. it does not mention the time that has passed (and the retryMaxDuration)
3. and it misses the original/last error message of the actual request (in my case I am sure there must have been any since retryMaxDuration was 60 sec, and socketTimeout 30 sec)

## Expected behavior

Change error message to something like this:

```
FetchError: retries reached max duration of 60 sec for https://example.com/some/url, last error: ECONNRESET
```

## More details

What's also interesting is that before that error I ONLY see maximum of 1 retry attempt before, with short initial retry delay:

```
AbortError failed with type: aborted; message: The user aborted a request.
Retrying in 107 milliseconds, attempt 1 error: AbortError, The user aborted a request.
AbortError failed with type: aborted; message: The user aborted a request.
Retrying in 182 milliseconds, attempt 1 error: AbortError, The user aborted a request.
```

I would have expected to see something like `Retrying in 30000 milliseconds, attempt 5` or similar before running into the retryMaxDuration limit.

There are many of those messages in the log output as my application makes many requests at the same time which all ran into some network limits at around the same time. They all have just log 1 retry attempt and then presumably work fine, except the one that failed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.