Closed wjianwei126 closed 7 years ago
Use of require within a thread function is currently not supported. To accomplish this would need some support from Node.js.
@wjianwei126 you can try to convert the whole module into a string and pass it to the worker.
https://github.com/icodeforlove/task.js/issues/20#issuecomment-236612517 https://github.com/icodeforlove/node-require-bundle
Do not you workaround this "FATAL ERROR: HandleScope::HandleScope" by using pools???
For example, if you call threadPool.any.eval(any_func());
you can use all your developed materials... including the require(s)
, no?
require
is not part of JavaScript, but is rather a feature of Node.js. webworker-threads imitates the WebWorker API so that your code can be used in both the browser and the Node.js environment. If you want to use require
, your code won't be portable anyway, in which case you'd be better off using the cluster
module or a child process-based pool with full require
support.
if you require('fs') is the thread function it will say FATAL ERROR: HandleScope::HandleScope Entering the V8 API without proper locking in place