Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retry error #477

Merged
merged 3 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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