photostructure / batch-cluster.js

Parallelized and efficient Node.js support for batch-mode child processes
https://photostructure.github.io/batch-cluster.js/
MIT License
14 stars 3 forks source link

BatchCluster.js setTimeout.unref is not a function #16

Closed Circuit8 closed 2 years ago

Circuit8 commented 2 years ago

I'm getting the following error intermittently while running exiftool-vendored v16.4.0, it didnt appear to be happening on v15.4.0.

Uncaught (in promise) TypeError: setTimeout(...).unref is not a function at BatchCluster._BatchCluster_maybeSpawnProcs

this error is being thrown in BatchCluster.js#462, where the following code is being executed:

setTimeout(__classPrivateFieldGet(this, _BatchCluster_onIdleLater, "f"), delay).unref();

I think the source line for this is here: https://github.com/photostructure/batch-cluster.js/blob/ea71a161575f375f5e3b4ebc6cc5716b52d9f80a/src/BatchCluster.ts#L558

I'm running it in an electron app, in the renderer, I wonder if this is relevant, I seem to remember there being a difference in the API of setTimeout in Node vs the browser which has caused me an issue with something before.

Let me know if I can help in anyway, and as ever, thanks for your awesome library!

mceachen commented 2 years ago

Thanks for the catch! The next version avoids global setTimeout and setInterval now.

(this is such a dumb node footgun! if they wanted a different timer or interval implementation don't name-collide with a global function)

Circuit8 commented 2 years ago

Awesome thanks alot. Yeah tell me about it, absolute madness!