Skip to content

Commit

Permalink
Fix retry error (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
sujaygarlanka authored Feb 25, 2020
1 parent 834f3f8 commit f1b3449
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## Next Release

- Fixed an issue where an error is thrown during a retry when a response is not returned by the previous call (#476).

## 1.31.0 [2020-02-13]

- Fix Authentication Request Retries
- Fixed Authentication Request Retries
- Added marker-based paging for users endpoints
- Added `getNextMarker()` to PagingIterator to get the next marker

Expand Down
4 changes: 2 additions & 2 deletions lib/api-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ APIRequest.prototype.getResponseStream = function() {
* @private
*/
APIRequest.prototype._handleResponse = function(err, response) {

// Clean sensitive headers here to prevent the user from accidentily using/logging them in prod
cleanSensitiveHeaders(this.request);

Expand Down Expand Up @@ -305,7 +305,7 @@ APIRequest.prototype._retry = function(err) {
this._finish(err);
return;
}
} else if (err.response.hasOwnProperty('headers') && err.response.headers.hasOwnProperty('retry-after')) {
} else if (err.hasOwnProperty('response') && err.response.hasOwnProperty('headers') && err.response.headers.hasOwnProperty('retry-after')) {
retryTimeout = err.response.headers['retry-after'] * 1000;
} else {
retryTimeout = getRetryTimeout(this.numRetries, this.config.retryIntervalMS);
Expand Down
2 changes: 1 addition & 1 deletion lib/token-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ TokenManager.prototype = {
}
throw error;
}
} else if (error.response.headers.hasOwnProperty('retry-after')) {
} else if (error.hasOwnProperty('response') && error.response.hasOwnProperty('headers') && error.response.headers.hasOwnProperty('retry-after')) {
retryTimeout = error.response.headers['retry-after'] * 1000;
} else {
retryTimeout = getRetryTimeout(numRetries, this.config.retryIntervalMS);
Expand Down

0 comments on commit f1b3449

Please sign in to comment.