Serialized Error: { code: 'ERR_DLOPEN_FAILED' } with electron-vite and vitest
MichaelJCole opened this issue · comments
Hi @murat-dogan
I'm using your package through as a dependency of the libp2p stack.
I'm having the issue below. You can find a reproduction here: https://github.com/MichaelJCole/node-datachannel-reproduction
The issue is:
FAIL src/main/test.test.js [ src/main/test.test.js ]
Error: Module did not self-register: '/home/michael/electron-app/node_modules/node-datachannel/build/Release/node_datachannel.node'.
❯ process.func [as dlopen] node:electron/js2c/node_init:2:2214
❯ Object.func [as .node] node:electron/js2c/node_init:2:2214
❯ Function.c._load node:electron/js2c/node_init:2:13672
❯ node_modules/node-datachannel/lib/index.js:5:25
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'ERR_DLOPEN_FAILED' }
I'm using the module with electron-vite and vitest. When I run vitest, I'm using electron's node like this:
"test": "ELECTRON_RUN_AS_NODE=1 electron node_modules/.bin/vitest"
npm run test
will pass on the first run, but if you hit enter, vitest will run the tests again and fail with the error.
I saw some other similar but different bugs. Is the module's registration re-entrant? Can it run more than once in the same node process?
Thank you!
Hello,
We are using node-addon-api and multiple loading should not be a problem.
I tried the same test with this project https://github.com/julusian/node-jpeg-turbo
It is also using cmake + node-addon-api
I could not regenerate the issue with node-jpeg-turbo.
Then I compared the cmake files and the problem is about CXX_STANDARD. (I don't know the reason)
If you create a hello world module and set the CXX_STANDARD version to 17, then you get the error.
By the way, I can not generate the issue with Jest.
libdatachannel (base lib) is using V17 as standard, so changing is not an option.
I do not have any idea about vite also.
Hi Murat, thank you. I'm not familiar with the tools and this is very helpful. I'll check in with vite and electron.