Skip to content

Commit

Permalink
Fixes S3 issue where aborted requests would trigger a bucket region l…
Browse files Browse the repository at this point in the history
…ookup in browsers (#1608)

* Fixes S3 issue where aborted requests would trigger a bucket region lookup in browsers

* Prevent Timeout errors from triggering a region lookup in browsers
  • Loading branch information
chrisradek authored Jul 12, 2017
1 parent 543add6 commit eb4dc87
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-S3-cba1d450.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "S3",
"description": "Updates S3 client to no longer attempt to determine a bucket's region when a request is aborted."
}
16 changes: 10 additions & 6 deletions lib/event_listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,16 @@ AWS.EventListeners = {
}

function error(err) {
resp.error = AWS.util.error(err, {
code: 'NetworkingError',
region: resp.request.httpRequest.region,
hostname: resp.request.httpRequest.endpoint.hostname,
retryable: true
});
if (err.code !== 'RequestAbortedError') {
var errCode = err.code === 'TimeoutError' ? err.code : 'NetworkingError';
err = AWS.util.error(err, {
code: errCode,
region: resp.request.httpRequest.region,
hostname: resp.request.httpRequest.endpoint.hostname,
retryable: true
});
}
resp.error = err;
resp.request.emit('httpError', [resp.error, resp], function() {
done();
});
Expand Down
8 changes: 8 additions & 0 deletions lib/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ AWS.Service = inherit({
* @api private
*/
retryableError: function retryableError(error) {
if (this.timeoutError(error)) return true;
if (this.networkingError(error)) return true;
if (this.expiredCredentialsError(error)) return true;
if (this.throttledError(error)) return true;
Expand All @@ -368,6 +369,13 @@ AWS.Service = inherit({
return error.code === 'NetworkingError';
},

/**
* @api private
*/
timeoutError: function timeoutError(error) {
return error.code === 'TimeoutError';
},

/**
* @api private
*/
Expand Down
54 changes: 51 additions & 3 deletions test/browser.spec.js

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

0 comments on commit eb4dc87

Please sign in to comment.