Open aurium opened 8 years ago
When event queue is empty, node eventloop close, webworker need to keep events in queue, like cluster module
I think this needs documentation.
I believe it is not a open question, it is a bug. @EduardoRFS makes a god point on event queue.
See the following issue: https://github.com/audreyt/node-webworker-threads/issues/93 -- basically, wrap with setImmediate
I had a similar issue first time using this module. Had something like this:
return new Promise((resolve, reject) => {
t.eval('fibo(10)', (err, result) => {
if (err) { return reject(err) }
resolve(result)
})
})
And it would hang for sometimes upwards of 30 seconds before responding. I thought it was theads being weird, building on windows, something.... changed it to wrap the resolution/rejection in setImmediate
and it works much better
return new Promise((resolve, reject) => {
t.eval('fibo(10)', (err, result) => {
setImmediate(() => {
if (err) { return reject(err) }
resolve(result)
})
})
})
Still having this issue over a year later :(
Hi! This module's functionality is now part of Node core https://nodejs.org/api/worker_threads.html
If you would like, I wonder if you (or someone interested) can help create a compatibility API on top of the core Node API and thus make this extension a polyfill only for earlier Node versions?
Hi folks. That is a weird bug or a big mistake. I need your help to solve anyway. I'm trying to make synaptic.js to work in parallel in node.js, and @Jabher point me this project to make the job without local WebWorker re-implementation. The problem is: with
webworker-threads
the mocha test freezes until timeout.I did simplify the test to point you where it happens without
synaptic.js
code:And it outputs:
As you can see, only when we mix
Promise
withwebworker-threads
the problem appear, and thethen()
was called, only after the timeout, doesn't matter how long it is.You can see why it need this test to work at
Trainer::trainAsync()
. I believe that can be a problem to many other possiblewebworker-threads
uses. That is not a problem if i implement the same feature withchild_process
module mimicking WebWorkers.Thanks.