Skip to content

Commit

Permalink
Retry http request on ECONNRESET error (#3739)
Browse files Browse the repository at this point in the history
  • Loading branch information
workeitel authored May 11, 2021
1 parent fefebc5 commit 649a91d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-retry-c648c8ae.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "retry",
"description": "Retry http request on ECONNRESET error"
}
8 changes: 6 additions & 2 deletions lib/http/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@ AWS.NodeHttpClient = AWS.util.inherit({
stream.abort();
});

stream.on('error', function() {
stream.on('error', function(err) {
if (connectTimeoutId) {
clearTimeout(connectTimeoutId);
connectTimeoutId = null;
}
if (stream.didCallback) return; stream.didCallback = true;
errCallback.apply(stream, arguments);
if ('ECONNRESET' === err.code || 'EPIPE' === err.code || 'ETIMEDOUT' === err.code) {
errCallback(AWS.util.error(err, {code: 'TimeoutError'}));
} else {
errCallback(err);
}
});

var expect = httpRequest.headers.Expect || httpRequest.headers.expect;
Expand Down
39 changes: 39 additions & 0 deletions test/node_http_client.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 649a91d

Please sign in to comment.