Open garygchai opened 7 years ago
For anyone wanting to solve this, here is my solution Using superagent own retry
.retry(3, (err, res) => {
if (err && err.message.includes("ECONNABORTED")) {
// test for this error catch
return true;
}
return false;
})
You could check for err to catch ECONNABORTED return true will retry request (you can even retry status 200) return false will not retry
The superagent lib will abort the request before retry, and the error code will be ECONNABORTED. So I suggest that add a retry at the
retries.js
. This error code was added at the superagent source code. https://github.com/visionmedia/superagent/blob/master/lib/should-retry.jsIn addition, if ECONNABORTED is added, one issue should be attention.
Some code like following:
when first time the request is aborted, the
this._aborted
will be true, and next time retry request, the request will be return. Show the code.So we can fix it at
reset
function.