Closed
Description
I've spent quite a bit of time trying to figure out why I'm getting
worker.js onmessage() captured an uncaught exception: ReferenceError: __filename is not defined
pthread sent an error! undefined:undefined: __filename is not defined
when trying to use PThreads in Node.js.
In the end, after looking at code, it hit me that this is a similar situation to the Web one. When using -s ENVIRONMENT=web
+ pthreads, Emscripten helpfully errors out with:
emcc: error: When building with multithreading enabled and a "-s ENVIRONMENT=" directive is specified, it must include "worker" as a target! (Try e.g. -s ENVIRONMENT=web,worker)
However, it doesn't in Node.js, and instead just produces broken code.
Same error should be extended to Node environment (or perhaps to general case whenever ENVIRONMENT
doesn't contain worker
).