Node retries not compatible with timeouts
See original GitHub issueI’m looking at integrating superagent to make a server side call to a flaky backend API. The API either responds quickly or doesn’t respond at all and needs to therefore be retried.
I’m therefore using retry(3)
in combination with timeout({ deadline: 3000 })
. However the timeout is overruling the retry and throwing an Aborted
error which returns a 500 error to the client. From what I can tell the following is happening when the request takes too long:
- Superagent makes a get request to backend API
GET
request times out so emits anabort
abort
handler thenreject
s the request- Retry logic kicks in and decides that we should retry
Aborted
error then causes 500 error to client- Backend API is then retried
- If API call fails then is retried twice more otherwise finishes
Looking at the code the retry logic attempts to reset the _aborted
and timedout
properties, but it looks like by then it is too late as reject
is called.
Is there a way I can therefore retry when the API call times out?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
Node retries not compatible with timeouts · Issue #1487
I'm looking at integrating superagent to make a server side call to a flaky backend API. The API either responds quickly or doesn't...
Read more >node.js - Nodejs http retry on timeout or error
I was looking for same thing and found interesting module requestretry, well suited for such requirement. Here is usage:
Read more >Error handling in Step Functions
This example of a Retry field retries any error except States.Timeout . "Retry": [ { "ErrorEquals": [ "States.Timeout" ], "MaxAttempts" ...
Read more >Cluster Timeouts | ScyllaDB Docs
Cluster Timeouts¶. Issue: cluster is experiencing timeouts due to server overload. Possible Root Cause: aggressive retry policy ...
Read more >How to fix DynamoDB timeouts in Serverless apps
In this post we are going to look at how to debug DynamoDB timeouts in Serverless apps. This is a fairly specific issue...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To reproduce:
and in another terminal, run a server that will not reply. Netcat will do:
v5.3.0 published to npm and GitHub releases page with changelog