You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been debugging why I keep getting returned that the limit has been reached even on the first call, and I found that somehow there is a bucket being returned in line 81 of tokenthrottle/index.js with all of the values set at NaN. This causes it to not create a new bucket with the options that I am sending in.
This is where I am initializing everything upon start up. I then store it in a factory and call it when I am about to POST or GET to another server (which is what I am throttle'ing). I am not sure why the a bucket is being returned or how to stop it from being returned or even where it is being created. Have you ever seen this before?
And this is where the bucket is being returned which is causing a new bucket to not be created on the first call
self.getter.call(self.table, key, function (err, bucket) {
if (err) {
return cb(new Error("Unable to check token table" + err))
}
if (bucket) {
// Recreate the token bucket
bucket = TokenBucket(bucket)
}
else {
// Make a new one
bucket = TokenBucket({
capacity: burst,
fillRate: rate,
window: wnd,
})
}
var hasCapacity = bucket.consume(1)
//console.log("Throttle(%s): num_tokens= %d -- throttled: %s", key, bucket.tokens, !hasCapacity)
self.putter.call(self.table, key, bucket, function (err) {
// Error here is not fatal -- we were able to determine throttle status, just not save state.
if (err) {
err = new Error("Error saving throttle information to table" + err)
}
if (!hasCapacity) {
return cb(err, true)
}
return cb(err, false)
})
})
Any help is appreciated. Please let me know if I did not provide enough information.
The text was updated successfully, but these errors were encountered:
I have been debugging why I keep getting returned that the limit has been reached even on the first call, and I found that somehow there is a bucket being returned in line 81 of tokenthrottle/index.js with all of the values set at NaN. This causes it to not create a new bucket with the options that I am sending in.
This is where I am initializing everything upon start up. I then store it in a factory and call it when I am about to POST or GET to another server (which is what I am throttle'ing). I am not sure why the a bucket is being returned or how to stop it from being returned or even where it is being created. Have you ever seen this before?
And this is where the bucket is being returned which is causing a new bucket to not be created on the first call
Any help is appreciated. Please let me know if I did not provide enough information.
The text was updated successfully, but these errors were encountered: