Skip to content

Commit

Permalink
Release 1.5.3 for fixed fixed error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel committed Sep 10, 2020
1 parent 3977f3d commit 2919331
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,7 @@ Region.prototype.get = function() {
reqConfig.headers = { [this.config.keyHeader]: this.config.key };
else
qs[this.config.keyQueryParam] = this.config.key;
return req(reqConfig).catch(err => {
this.liveRequests--;
if (err.error && 'ETIMEDOUT' === err.error.code && retries < this.config.retries) { // Retry connection timeouts.
retries++;
return fn();
}
throw new Error('Failed after ' + retries + ' retries due to: ' + err.message);
}).then(res => {
return req(reqConfig).then(res => {
this.liveRequests--;
rateLimits.forEach(rl => rl.onResponse(res));
if (400 === res.statusCode)
Expand All @@ -118,6 +111,13 @@ Region.prototype.get = function() {
return fn();
}
return JSON.parse(res.body);
}, err => {
this.liveRequests--;
if (err.error && 'ETIMEDOUT' === err.error.code && retries < this.config.retries) { // Retry connection timeouts.
retries++;
return fn();
}
throw new Error('Failed after ' + retries + ' retries due to: ' + err.message);
});
};
return Promise.resolve(fn());
Expand Down Expand Up @@ -158,8 +158,8 @@ RateLimit.prototype.onResponse = function(res) {
}
}

let limitHeader = res.headers[this.type.headerLimit];
let countHeader = res.headers[this.type.headerCount];
const limitHeader = res.headers[this.type.headerLimit];
const countHeader = res.headers[this.type.headerCount];
if (this._bucketsNeedUpdate(limitHeader, countHeader))
this.buckets = RateLimit._getBucketsFromHeaders(limitHeader, countHeader);
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "teemojs",
"version": "1.5.2",
"version": "1.5.3",
"description": "A Fast & Lightweight Riot API Wrapper",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 2919331

Please sign in to comment.