PeculiarVentures / pkcs11js

A Node.js implementation of the PKCS#11 2.40 interface
MIT License
107 stars 33 forks source link

Module did not self-register #82

Open willin opened 3 years ago

willin commented 3 years ago
Trace: Error: Module did not self-register: '/root/baas/fabric-baas-backend/node_modules/pkcs11js/build/Release/pkcs11.node'.
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/root/baas/fabric-baas-backend/node_modules/pkcs11js/index.js:5:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/root/baas/fabric-baas-backend/node_modules/fabric-network/node_modules/fabric-common/lib/impl/bccsp_pkcs11.js:27:18)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/root/baas/fabric-baas-backend/node_modules/fabric-network/node_modules/fabric-common/lib/User.js:12:28)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at /root/baas/fabric-baas-backend/packages/server-synchronizer/dist/tasks/sync_orgsandpeersfromchannel.js:57:123
    at async syncOrgsAndPeersFromNetworkChannel (/root/baas/fabric-baas-backend/packages/server-synchronizer/dist/tasks/sync_orgsandpeersfromchannel.js:57:40)

in worker threads

npm rebuild no use. if i dont use threads.js it can work properly

microshine commented 3 years ago

I've reproduced that exception. Looking for solution how to fi it

microshine commented 3 years ago

It throws Module did not self-register for the next script

process.dlopen(module, path.resolve(__dirname, "../build/Release/pkcs11.node"));
process.dlopen(module, path.resolve(__dirname, "../build/Release/pkcs11.node"));

I did some experiments with HellloWorld examples (C++ addons and C++ N-API addons). These addons don't allow loading multiple times too

lankke commented 1 year ago

I came across the same error when I tried to include pkcs11js as a dependency to an Insomnia plugin I am developing.

Was there any insight into how to fix this problem? If the multi-threaded aspect is the cause, I might not be able to use this library as a dependency for my plugin.

lankke commented 1 year ago

I'm going to fork the repo and have a go at solving this issue. It doesn't seem to be a high priority issue but it would be great to have a pcks11 module that could be used in plugin development. I may have the solution for making the module context aware and therefore solving the multi-threaded issue.