Skip to content

Commit 625abe0

Browse files
Update Rate Limits on catch (#85, thanks to @cedricdelpoux)
Before metrics could be off for failed requests when using promise flow
1 parent 346f6c3 commit 625abe0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/httpClient.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ HttpClient.prototype._requestHelper = function (options, done) {
189189
limits = rateLimiting.updateRateLimits(response.headers)
190190
return Promise.resolve(response.body)
191191
})
192+
.catch((e) => {
193+
if (e.response && e.response.headers) {
194+
limits = rateLimiting.updateRateLimits(e.response.headers)
195+
}
196+
197+
return Promise.reject(e)
198+
})
192199
.asCallback(callback)
193200
}
194201

0 commit comments

Comments
 (0)