Loupi / node-cypher-parser

A Cypher parser/linter addon module for NodeJS.
MIT License
37 stars 8 forks source link

Attempting to use from worker_thread throws "Module did not self register" #36

Closed steveliles closed 1 year ago

steveliles commented 1 year ago

I'm trying to spin up worker threads (https://nodejs.org/api/worker_threads.html) to take advantage of multiple cpu cores in a project that uses node-cypher-parser, but I get this error:

Error: Module did not self-register: '/Users/Steve/myproject/node_modules/cypher-parser/dist/release/cypher.node'.

Apparently this is to do with native add-ons having to be aware that they might be used from worker threads, and for many modules the fix is relatively simple: https://github.com/nodejs/node/issues/21783#issuecomment-429637117

Documentation for context-aware addons and some worker_thread specific stuff about cleaning up resources here: https://github.com/nodejs/node/blob/main/doc/api/addons.md#context-aware-addons

I will try to fork and PR but I have not done any native before, so I'm not massively confident of success ...