node-java icon indicating copy to clipboard operation
node-java copied to clipboard

'Error: Module did not self-register.' with Worker Threads

Open davideutsch opened this issue 4 years ago • 3 comments

When I try to use the library in multiple threads (worker_threads), I get Error: Module did not self-register. exception. Within the main thread no problems arise, however as soon as a new worker is created this error is thrown.

Environment

  • Node version: 12.18.1
  • Typescript: 3.6.4

Full Stack Trace

Error: Module did not self-register: '\\?\C:\projectFolder\node_modules\java\build\Release\nodejavabridge_bindings.node' 
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1188:18)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\projectFolder\node_modules\java\lib\nodeJavaBridge.js:21:16)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Module._compile (C:\projectFolder\node_modules\source-map-support\source-map-support.js:547:25)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32) 

The error can supposedly be fixed with the following: https://github.com/nodejs/node/issues/21783#issuecomment-429637117

davideutsch avatar Sep 15 '21 07:09 davideutsch

I'm experiencing the same error and i can't find a solution.

tonioss22 avatar Jan 07 '22 20:01 tonioss22

I've looked more into it this morning and it seems that making it context aware does work and fix the issue but it also causes the software to close on itself as soon as you use java without any error message. I have not been able to fix this issue yet. This only occurs when using node-java inside a worker thread since when doing the testRunner script, it does not crash until i get to my worker thread test script.

tonioss22 avatar Jan 10 '22 15:01 tonioss22

Hi @tonioss22 Can you please share information on how did you fix the issue?

finddeepali avatar Aug 29 '23 12:08 finddeepali