Closed nomagick closed 2 years ago
This throws exception in react:
Uncaught TypeError: setTimeout(...).unref is not a function
This throws exception in react:
Uncaught TypeError: setTimeout(...).unref is not a function
u running this in browser or node.js or some other javascript runtime?
In chrome, yes
This project is node-pool
and Generic resource pooling for node.js
So I think it's ok to rely on node.js only features.
setTimeout
returns a timer in node.js, while in browsers, it returns an integer.
I guess u need to fork and change the code for if you need this library in the browser.
Simply remove the .unref
part cuz in browsers u don't need to worry about timer references and quitting the process.
Actually, in npm, it is called 'generic-pool', and there is no statement that says it's exclusively for Node.js. Is there anything that makes the library Node.js only? Shouldn't we just change the call to .unref?.()
and support browsers?
Actually, in npm, it is called 'generic-pool'
@tal952 I see. I created another PR for this. It's not tested. I just modified the code in my browser.
I'm using
generic-pool
in another library. The end developer may not be aware there's a pool running under the hood. Thus unable todrain().then(clear())
.As a library, don't block the process quit. Simply
unref
all thesetTimeout
s.