CraZySacX / node-jdbc

JDBC Wrapper for node.js
140 stars 107 forks source link

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

Open davideutsch opened 3 years ago

davideutsch commented 3 years ago

When I try to use the jdbc or jinst library in multiple threads, I get Error: Module did not self-register. exception.

Reproduction steps

import { isMainThread, Worker } from 'worker_threads';

if (isMainThread) {
  require('jdbc/lib/jinst'); 
  require('jdbc/lib/pool'); 
  new Worker(__filename);
} else {
  require('jdbc/lib/jinst'); // throws: `Error: Module did not self-register.` 
  require('jdbc/lib/pool'); // throws: `Error: Module did not self-register.` 
}

Environment

tonioss22 commented 2 years ago

This is an issue with node-java, node-java needs to be converted to be context aware.