Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module did not self-register #162

Open
xobotyi opened this issue Mar 16, 2022 · 6 comments
Open

Module did not self-register #162

xobotyi opened this issue Mar 16, 2022 · 6 comments

Comments

@xobotyi
Copy link

xobotyi commented Mar 16, 2022

When trying to use mmagic within worker threads im receivenig below error:

Module did not self-register: '****\node_modules\mmmagic\build\Release\magic.node'.
node:internal/modules/cjs/loader:1183
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: Module did not self-register: '****\node_modules\mmmagic\build\Release\magic.node'.
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (****\node_modules\mmmagic\lib\index.js:1:13)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at require.extensions.<computed> (****\node_modules\ts-node\src\index.ts:1361:43)
    at Object.require.extensions.<computed> [as .js] 

node: v16.13.2
os: Windows 11

While being used within main thread - everything works just fine.

@xobotyi
Copy link
Author

xobotyi commented Mar 16, 2022

I've managed to workaround and it is simply exclusion of mmm.Magic instance from thread, but it seems not the best solution.

@mscdex
Copy link
Owner

mscdex commented Mar 16, 2022

mmmagic is not compatible with workers at the moment.

@kj800x
Copy link

kj800x commented Jun 4, 2022

@mscdex I've also got a case where I need to use mmmagic from a worker thread. It looks like the first step towards unblocking that would be migrating from nan to node-api. I believe this would also change the minimum node version to at least 8.6.0 since that was when node-api was introduced.

Would there be any interest in a PR for that or would it be too drastic of a change?

@mscdex
Copy link
Owner

mscdex commented Jun 4, 2022

I'm not comfortable using node-api yet. AFAIK nan has a way to mark a module as worker-friendly, but of course that requires some code changes because you need to make sure that (per-worker/isolate/whatever) resources are properly cleaned up whereas currently there are some globals used.

@tnabil
Copy link

tnabil commented Mar 9, 2023

I've managed to workaround and it is simply exclusion of mmm.Magic instance from thread, but it seems not the best solution.

Hi @xobotyi, could you please elaborate a bit on this workaround? How did you exclude the package from the worker thread?

@xobotyi
Copy link
Author

xobotyi commented Mar 22, 2023

@tnabil just rethinked the flow and been able to use mmmagic in main thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants