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

App is throwing the error while running electron 14.0.0 and better-sqlite3 #694

Closed
akash07k opened this issue Sep 3, 2021 · 33 comments
Closed

Comments

@akash07k
Copy link

akash07k commented Sep 3, 2021

Description:
I'm using electron 14.0.0 and latest version of better-sqlite3 package.
However, when I try to run my app I get the following error:
Compiling Renderer Code[13984:0903/144946.475:ERROR:crashpad_client_win.cc(808)] not connected
And my app exits.
Steps to reproduce:

  1. use npx create-electron-app --template="webpack to create/initialize a fresh new electron app with ElectronForge.
  2. Now execute npm install better-sqlite3.
  3. Require better-sqlite3 in your main.js file: (let db = require("better-sqlite3");)
  4. Now execute npm start and observe.
  5. The app will throw the error such as:
    Compiling Renderer Code[13984:0903/144946.475:ERROR:crashpad_client_win.cc(808)] not connected

(This error doesn't come if we use Electron 13.3.0)

@JoshuaWise

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Sep 3, 2021

I can reproduce this with a vanilla project as well (without all the bells and whistles of create-electron-app). This error seems to come up frequently with other native modules as well https://github.com/search?o=desc&q=_ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE&s=&type=Issues

I am kind of confused, because I can't seem to make npm rebuild or electron-rebuild actually make it rebuild from scratch. And since there is no prebuild for Electron 14 I have no idea what it's actually installing?

So I'm not sure on which end this needs to be fixed.

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Sep 3, 2021

I might be entirely lost, but maybe this is related to the fact that both Electron 13 and 14 use ABI 89. That means it pulls the prebuild for ABI 89 but it was compiled for Electron 13. The prebuilds need to be for a given Electron version, not ABI version. There needs to be a prebuild for 13 AND for 14, not a single 89. Does that make sense? Maybe this was the first Electron major release without ABI bump, at least since better-sqlite3 has prebuilds (see https://github.com/electron/node-abi/blob/master/abi_registry.json).

Edit:

Currently:

better-sqlite3-v7.4.3-electron-v89-linux-x64.tar.gz

Future?

better-sqlite3-v7.4.3-electron-v13-linux-x64.tar.gz
better-sqlite3-v7.4.3-electron-v14-linux-x64.tar.gz

But I don't really know a lot about this. Maybe the ABI version is the only thing relevant for compatibility? If so, then why doesn't it work?

@akash07k
Copy link
Author

akash07k commented Sep 3, 2021

Ya, you are right.
I too agree with you.
It may be possible that it may need to be compiled/built for electron V14 in order to make it work but I don't know that how to acomplish it.

I might be entirely lost, but maybe this is related to the fact that both Electron 13 and 14 use ABI 89. That means it pulls the prebuild for ABI 89 but it was compiled for Electron 13. The prebuilds need to be for a given Electron version, not ABI version. There needs to be a prebuild for 13 AND for 14, not a single 89. Does that make sense? Maybe this was the first Electron major release without ABI bump, at least since better-sqlite3 has prebuilds (see https://github.com/electron/node-abi/blob/master/abi_registry.json).

Edit:

Currently:

better-sqlite3-v7.4.3-electron-v89-linux-x64.tar.gz

Future?

better-sqlite3-v7.4.3-electron-v13-linux-x64.tar.gz
better-sqlite3-v7.4.3-electron-v14-linux-x64.tar.gz

But I don't really know a lot about this. Maybe the ABI version is the only thing relevant for compatibility? If so, then why doesn't it work?

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Sep 3, 2021

This could potentially be fixed by upgrading prebuild-install https://github.com/JoshuaWise/better-sqlite3/blob/master/package.json#L14

Because of electron/node-abi#104 but it's not in yet https://github.com/prebuild/prebuild-install/blob/c96c526d360b2e8ce0ece5b9e3c06b13082ea74e/package.json#L29

Manually doing npm i node-abi@2.30.1 doesn't fix it, so yeah. Maybe that needs to happen in the better-sqlite3 CI first to create new prebuilds.

@akash07k
Copy link
Author

akash07k commented Sep 3, 2021

Cool, so how can I incorporate the fix at my side so that I can run electron 14 with better-sqlite3?

This could potentially be fixed by upgrading prebuild-install https://github.com/JoshuaWise/better-sqlite3/blob/master/package.json#L14

Because of electron/node-abi#104 but it's not in yet https://github.com/prebuild/prebuild-install/blob/c96c526d360b2e8ce0ece5b9e3c06b13082ea74e/package.json#L29

Manually doing npm i node-abi@2.30.1 doesn't fix it, so yeah. Maybe that needs to happen in the better-sqlite3 CI first to create new prebuilds.

@akash07k akash07k closed this as completed Sep 3, 2021
@akash07k akash07k reopened this Sep 3, 2021
@rayzorben
Copy link

Is there anything that can be done in the meantime? I tried going back to electron@13.2.3 but that doesn't seem to be working now either.

@barbalex
Copy link

barbalex commented Sep 9, 2021

I have the same problem. When using electron v14 this happens when upgrading better-sqlite3 beyond v7.4.0.
It seems that adding prebuilt binaries may have caused this: https://github.com/JoshuaWise/better-sqlite3/releases/tag/v7.4.1
Could it be that a node mismatch is created with electron?

@akash07k
Copy link
Author

akash07k commented Sep 9, 2021 via email

@barbalex
Copy link

barbalex commented Sep 9, 2021

@akash07k have you tried using v7.4.0? That is the last version that works for me.
If the reason is a node mismatch then probably versions beyond 7.4.0 will not work in lower versions of electron either.

@akash07k
Copy link
Author

akash07k commented Sep 9, 2021

No, not tried, but going to try now.

@akash07k have you tried using v7.4.0? That is the last version that works for me.
If the reason is a node mismatch then probably versions beyond 7.4.0 will not work in lower versions of electron either.

@akash07k
Copy link
Author

Yes bro, I tried with 7.4.0.
It works fine.
@JoshuaWise
Any update on this?

@akash07k have you tried using v7.4.0? That is the last version that works for me.
If the reason is a node mismatch then probably versions beyond 7.4.0 will not work in lower versions of electron either.

@barbalex
Copy link

I am not sure if the issue is with better-sqlite3 or with the build tools used with electron.

@akash07k
Copy link
Author

akash07k commented Sep 10, 2021 via email

@Tenison
Copy link

Tenison commented Sep 17, 2021

//First Uninstall  better-sqlite3
npm uninstall better-sqlite3
//use version 7.4.0
npm install better-sqlite3@7.4.0 

npm uninstall electron
//use version 13
npm install electron@~13.4.0

//install electron-rebuild
npm i -D electron-rebuild
// Delete both "node-modules" folder, as well as the "packages-lock.json"
//reinstall using
npm i
//rebuild packages
./node_modules/.bin/electron-rebuild    //run for mac 
.\node_modules\.bin\electron-rebuild.cmd  //run for windows

/////that solved my problem

///Use electron-packager to build your app
npm install -g electron-packager --save-dev
npx electron-packager <appDirectory> appName --overwrite --asar --electron-version=13.4.0 --platform=win32 --arch=x64 --prune=true --out=release-builds --icon=./build/icon.ico"

@akash07k
Copy link
Author

No, this is not the way for the users who want to use electron 14 with their apps.
Although as of now I'm using better-sqlite3 7.4.0 for the time being

//First Uninstall  better-sqlite3
npm uninstall better-sqlite3
//use version 7.4.0
npm install better-sqlite3@7.4.0 

npm uninstall electron
//use version 13
npm install electron@~13.4.0

//install electron-rebuild
npm i -D electron-rebuild
// Delete both "node-modules" folder, as well as the "packages-lock.json"
//reinstall using
npm i
//rebuild packages
./node_modules/.bin/electron-rebuild    //run for mac 
.\node_modules\.bin\electron-rebuild.cmd  //run for windows

/////that solved my problem

///Use electron-packager to build your app
npm install -g electron-packager --save-dev
npx electron-packager <appDirectory> appName --overwrite --asar --electron-version=13.4.0 --platform=win32 --arch=x64 --prune=true --out=release-builds --icon=./build/icon.ico"

@Tenison
Copy link

Tenison commented Sep 17, 2021

Yes definitely, but until the issue is resolved, this is the solution I'm using.
Did yours work with electron 14, because mine does not

@akash07k
Copy link
Author

Yes, better-sqlite3 7.4.0 works well with electron 14.

Yes definitely, but until the issue is resolved, this is the solution I'm using.
Did yours work with electron 14, because mine does not

@Tenison
Copy link

Tenison commented Sep 17, 2021

Yes, better-sqlite3 7.4.0 works well with electron 14.

Yes definitely, but until the issue is resolved, this is the solution I'm using.
Did yours work with electron 14, because mine does not

KK.. I will try it out

@lazytyper
Copy link

I've been trying to integrate better-sqlite3 with Electron, I've found this solution:

https://ishwar-rimal.medium.com/integrating-sqlite3-in-electron-project-build-with-electron-forge-6d4d634b8648

But, it seems it to work on Windows, but I'm using Linux.

I also found this issue posted on electron-rebuild:

electron-rebuild properly rebuilds better-sqlite3 on Windows, but skips the rebuild on Linux
electron/rebuild#591

mceachen added a commit to mceachen/better-sqlite3 that referenced this issue Sep 25, 2021
@mceachen
Copy link
Member

mceachen commented Sep 25, 2021

@JoshuaWise I poked at this a bit just now.

prebuild-install can be forced to rebuild by setting the environment variable npm_config_build_from_source=true, but using the currently-released version (6.0.1), I still got

(node:2357177) UnhandledPromiseRejectionWarning: Error: The module '/tmp/.mount_PhotoS9hayLP/resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 89. This version of Node.js requires
NODE_MODULE_VERSION 98. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

I cloned better-sqlite3 into a local directory, ran npx ncu -u which pulled in "prebuild-install": "^6.1.4", changed my package.json to point to that new directory, and everything looks good.

TL;DR: please upgrade your prebuild-install dependency. #702 should take care of it.

(Also, TIL that prebuild now recommends transitioning to prebuildify paired with node-gyp-build. More context here)

@cloverich
Copy link

I adapted renkei's workaround slightly to directly call npm rebuild providing the target versions. I don't really understand how it uses the electron version properly ¯_(ツ)_/¯

#!/bin/bash

# Adapted from:
# https://github.com/electron/electron-rebuild/issues/591

# Electron's version.
# example of electron -v --> v15.1.1
export npm_config_target=$(npx electron -v)

# The architecture of Electron, see https://electronjs.org/docs/tutorial/support#supported-platforms
# for supported architectures.
export npm_config_arch=x64
export npm_config_target_arch=x64

# Download headers for Electron.
export npm_config_disturl=https://electronjs.org/headers

# Tell node-pre-gyp that we are building for Electron.
export npm_config_runtime=electron

# Tell node-pre-gyp to build module from source code.
export npm_config_build_from_source=true

HOME=~/.electron-gyp npm rebuild better-sqlite3

@cloverich
Copy link

cloverich commented Oct 6, 2021

Towards @mceachen 's upgrade fix I am betting build from source being ignored patch was the culprit

@JoshuaWise
Copy link
Member

This should be fixed in v7.4.4.

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Oct 25, 2021

Can anyone confirm this is working for them? For me I still can't get electron-rebuild to make to correct version for Electron 14 or 15. And my observations above seem to still hold true that the entire chain of dependencies is still borked because it relies on an outdated node-abi version. That means prebuild needs an update as it still points at the old node-abi. And after that has happened better-sqlite3 needs to push a new update to trigger another run of builds. Right?

@mceachen
Copy link
Member

Electron 15 is still broken. See #713 (comment)

@mceachen mceachen reopened this Oct 25, 2021
@m4heshd
Copy link
Contributor

m4heshd commented Nov 14, 2021

@Prinzhorn No need for a rebuild. We simply have to wait till app-builder-bin is fixed. (electron-userland/electron-builder#6352 (comment))

Scratch that. Just need prebuild-install updated and all good. Prebuilds are still good. No need for a rebuild.

@barbalex
Copy link

Version 7.4.5 works for me. Thanks!

@JoshuaWise
Copy link
Member

Thanks @barbalex. Closing this, but would appreciate more confirmations that it is working for people in 7.4.5

@Prinzhorn
Copy link
Contributor

I recently migrated to Electron 16 and it went smooth. So I can confirm that it works with the latest Electron + better-sqlite3. Can't speak for older combinations.

@barbalex
Copy link

barbalex commented Jan 5, 2022

I just got this again in two projects after having updated to v7.4.6 and electron 16.0.6. Reverting to v7.4.5 solved the issue

@YOSSTM
Copy link

YOSSTM commented Aug 29, 2022

I just want to add something , it works at build time but in the release didn't work .I'm using electron 15

@Johanbos
Copy link

Johanbos commented Sep 2, 2023

I've encountered this issue with Electron 26 & better-sqlite3 v8.5.x. Going to see which downgrade works again :(

@xchgrbprsp
Copy link

I've encountered this issue with Electron 26 & better-sqlite3 v8.5.x. Going to see which downgrade works again :(

I just got the same issue with Electron 26.1.0. Had to downgrade to 25.4.0 and it worked again.

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

No branches or pull requests