coopernurse / node-pool

Generic resource pooling for node.js
2.37k stars 259 forks source link

It does not respect when maxWaitingClients is set to 0 #234

Closed anupbaldawa closed 5 years ago

anupbaldawa commented 6 years ago

I want my code to fail when I set maxWaitingClients to 0.

I looked into the code and it seems that if I pass in 0, then it is ignored as the if condition is false.

https://github.com/coopernurse/node-pool/blob/master/lib/PoolOptions.js#L75

sandfox commented 6 years ago

good catch, as I wrote that code over 2 years ago I'm not exactly sure what the intention was but I strongly expect that I just wasn't paying attention to that case. I'll gladly except a PR that does something like:

    if (opts.maxWaitingClients != undefined) {
      // @ts-ignore
      this.maxWaitingClients = parseInt(opts.maxWaitingClients, 10);
    }
anupbaldawa commented 6 years ago

Here is the PR: https://github.com/coopernurse/node-pool/pull/235

Thanks Anup

anupbaldawa commented 6 years ago

I have created another PR with test cases. https://github.com/coopernurse/node-pool/pull/236