Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined requestsPerSeconds gives an infinite loop #85

Open
amrltqt opened this issue Nov 21, 2020 · 0 comments
Open

Undefined requestsPerSeconds gives an infinite loop #85

amrltqt opened this issue Nov 21, 2020 · 0 comments

Comments

@amrltqt
Copy link

amrltqt commented Nov 21, 2020

Several days ago, I've made a typo while configuring a PromiseThrottle on the requestsPerSeconds awaited field. Consequently, the object was configured with an undefined requestsPerSeconds value and my sequence of promise was obviously not fired.

After a small deep diving a bit, I've finally understood that the undefined have been transformed into a NaN while computing the value inc = (1000 / this.requestsPerSecond) * weight. The NaN is propagated in the instruction on below and make the if (the this._execute();) unsolvable.

if (elapsed >= inc) {
    this._execute();
} else {
    // we have reached the limit, schedule a dequeue operation
    setTimeout(function() {
        this.dequeue();
    }.bind(this), inc - elapsed);
}

Is it possible to add some warning or trigger some error in case of undefined or NaN value? I would be happy to send you a PR for that if you need to!

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

No branches or pull requests

1 participant