Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

possible error in quota handling? #114

Open
ericblade opened this issue Jan 9, 2019 · 7 comments
Open

possible error in quota handling? #114

ericblade opened this issue Jan 9, 2019 · 7 comments

Comments

@ericblade
Copy link
Owner

just received this on my service, a few times, i'm not sure if it's related to the new quota handling code, or if it's something inside my app service.

(node:13300) TimeoutOverflowWarning: Infinity does not fit into a 32-bit signed integer.
@pwrnrd
Copy link
Contributor

pwrnrd commented Jan 9, 2019

Are you running your app on #113?

What version of Node are you running? I'm on 10.9.0.

@ericblade
Copy link
Owner Author

service is on node 9.6.1 right now, and i'm reasonably certain it's using the most recent commit here . . . i haven't replicated the problem, yet, but it does seem that somewhere someone has done a setTimeout with Infinity, which doesn't sound like anything i'm doing on the app that uses mws-advanced... but i need to go over it with a comb to make sure.

@pwrnrd
Copy link
Contributor

pwrnrd commented Jan 10, 2019

I'm writing some test functions for Queue (also see my pull request) and I encountered the same error when running into a max quota without setting a restore rate.

I think the problem is in the following:

const time = (((60 / this.restoreRate) || 1) * 1000) + 250;

The default restore rate is 0. Hence, this expresspession evaluates to inifity.

In addition, the following in index.js might also cause the restore rate to be 0:

restoreRate: (endpoint.throttle && endpoint.throttle.restoreRate) || 0,

Hope this helps.

@pwrnrd
Copy link
Contributor

pwrnrd commented Jan 10, 2019

There is also a timer in Queue.complete() which might return infinity:

 const time = (((60 / this.restoreRate) || 1) * 1000 * this.maxInFlight) + 250;
 if (this.resetDrainTimeout) {
       clearTimeout(this.resetDrainTimeout);
  }
  this.resetDrainTimeout = setTimeout(() => { this.singleDrain = false; }, time);

@ericblade
Copy link
Owner Author

Thanks for finding that, I had a feeling that was something involving time and division. I honestly thought node would throw a runtime error for division by zero rather than returning Infinity, though. heh.

looks to me like it should be
const time = (60 / (this.restoreRate || 1) * 1000 * this.maxInFlight) + 250;
or something like that.
i wonder what i'm calling that doesn't have the throttle data filled in.

@pwrnrd
Copy link
Contributor

pwrnrd commented Jan 10, 2019

i wonder what i'm calling that doesn't have the throttle data filled in.

Exactly! I was thinking about setting the default value to 1. But than I thought, perhaps we should throw an error. Personally I have a preference for an error, because I don't expect that we'll ever have to deal with an MWS endpoint which has no restore rate.

@ericblade
Copy link
Owner Author

well, there's a bunch of quota rate that just has never had the data filled in, and i'm not sure if that's because documentation was lacking, or i just didn't get to it, because the calls weren't useful to my purposes at the time. i might be using a mws call that doesn't have a helper wrapper thing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants