Protect against NaN task cost

This commit is contained in:
Christopher Willis-Ford 2018-08-31 11:35:54 -07:00
parent c8dc8fb5b9
commit 28621c9860

View file

@ -117,7 +117,7 @@ class TokenBucket {
if (cost <= this._tokenCount) {
return Promise.resolve();
}
if (cost > this._limit) {
if (!(cost <= this._limit)) {
return Promise.reject(new Error('Task cost is greater than bucket limit'));
}
return new Promise(resolve => {