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

Electron 6 causes DLL init error when using NAPI native modules #19884

Closed
3 tasks done
Superlokkus opened this issue Aug 22, 2019 · 4 comments
Closed
3 tasks done

Electron 6 causes DLL init error when using NAPI native modules #19884

Superlokkus opened this issue Aug 22, 2019 · 4 comments

Comments

@Superlokkus
Copy link

Superlokkus commented Aug 22, 2019

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version: 6.0.3
  • Operating System: Windows 10 1903
  • Last Known Working Electron version: 3.1.13
  • Build System: Microsoft (R) C/C++ Optimizing Compiler Version 19.22.27905 for x64 aka Visual Studio 2019

Expected Behavior

Native node module still works in new electron version

Actual Behavior

DLL initialization error at runtime

To Reproduce

Yarn install and yarn dist of https://github.com/Superlokkus/electron-native-node-demo/tree/actual_napi_use_with_electron_update
Then run the executable: DLL error

Yarn install and yarn dist https://github.com/Superlokkus/electron-native-node-demo/tree/actual_napi_use
Then run the executable: Works as intended

Only difference (assumed) between the branches: New electron version.

Error

Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\?\C:\Users\marku\AppData\Local\Programs\electron_native_node_demo\resources\app.asar.unpacked\node_modules\spielwiese\build\Release\spielwiese.node
at process.func (electron/js2c/asar.js:155)
at process.func [as dlopen] (electron/js2c/asar.js:155)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:828)
at Object.func (electron/js2c/asar.js:155)
at Object.func [as .node] (electron/js2c/asar.js:164)
at Module.load (internal/modules/cjs/loader.js:645)
at Function.Module._load (internal/modules/cjs/loader.js:560)
at Module.require (internal/modules/cjs/loader.js:685)
at require (internal/modules/cjs/helpers.js:16)
at index.html:10

Screenshots

Additional Information

@reanimatedmanx
Copy link

Yeah same problem I've bump into yesterday. The fun fact that the stack trace is fun as hell', I tried to debug but I believe devs from electron have a better knowledge how to do it well.
Hopefully it will be fixed soon, thanks gl hf!

@greg9504
Copy link

greg9504 commented Sep 6, 2019

FWIW I have built an add on that used n-api and it works with Electron 6. I took a quick look and built your distribution. However you are using CMake-js to build your plugin and I can't really see the magic it is doing. My guess is the problem lies there, not with Electron. Try building it with node-gyp and then use electron-builder to rebuild your plugin targeting Electron via the install-app-deps command. I have these scripts setup to do that:

"postinstall": "npm run postinstall:electron && npx electron-builder install-app-deps",
"postinstall:electron": "node postinstall",

@xhcoding
Copy link

xhcoding commented Sep 9, 2019

If you use CMake-js to build addon for electron > 4, you shoule add ${CMAKE_JS_SRC} to you sources.Look #17462 and https://github.com/cmake-js/cmake-js#general

@Superlokkus
Copy link
Author

If you use CMake-js to build addon for electron > 4, you shoule add ${CMAKE_JS_SRC} to you sources.Look #17462 and https://github.com/cmake-js/cmake-js#general

Yes that solved the problem, sorry did not saw that update in the cmake-js documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
6.1.x
Unsorted Issues
Development

No branches or pull requests

5 participants