Skip to content

Commit

Permalink
Update Rate Limits on catch (#85, thanks to @cedricdelpoux)
Browse files Browse the repository at this point in the history
Before metrics could be off for failed requests when using promise flow
  • Loading branch information
cedricdelpoux authored Feb 6, 2020
1 parent 346f6c3 commit 625abe0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/httpClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ HttpClient.prototype._requestHelper = function (options, done) {
limits = rateLimiting.updateRateLimits(response.headers)
return Promise.resolve(response.body)
})
.catch((e) => {
if (e.response && e.response.headers) {
limits = rateLimiting.updateRateLimits(e.response.headers)
}

return Promise.reject(e)
})
.asCallback(callback)
}

Expand Down

0 comments on commit 625abe0

Please sign in to comment.