WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.37k stars 394 forks source link

Add support for electron `v26` prebuilds #1042

Closed m4heshd closed 1 year ago

m4heshd commented 1 year ago

Stable electron v26 just released. Prebuilds were tested here.

felixrieseberg commented 1 year ago

(I just want to say thank you!)

KillerCodeMonkey commented 1 year ago

is it possible to automate this? grab all major versions of the electron npm package -> build for latest x versions?

Electron only supports the latest 3 major versions. so maybe for older projects support the latest 5.

m4heshd commented 1 year ago

is it possible to automate this?

Possible but not recommended. The whole dependency tree responsible for building is way too unreliable for automation to be stable. We always say a quick prayer before building for the latest Electron release.

Electron only supports the latest 3 major versions. so maybe for older projects support the latest 5.

The prebuild support is determined by whatever Node versions are being actively supported. That's why we still build for Electron v16, which ships with embedded Node v16 (still in active maintenance).

KillerCodeMonkey commented 1 year ago

@m4heshd alrighty. i just asked it for the electron part, because you are building it for very old electron versions, which are not supported by electron for a long time. but i am fine with your answer. thank you very much :)

m4heshd commented 1 year ago

i just asked it for the electron part

That's exactly what I explained. Even though Electron drops support for these versions pretty quickly, they still ship with actively maintained Node versions (I'm assuming here that you already know about how Electron carries its own copy of Node as a library).

If you run Electron v16 with ELECTRON_RUN_AS_NODE=1 env, it'll simply run the Node v16 runtime, just with a different ABI version tag. That's why we build for super old Electron versions.

KillerCodeMonkey commented 1 year ago

(I'm assuming here that you already know about how Electron carries its own copy of Node as a library).

Yes (And i got in trouble because of that (i am looking at you openssl vs boringssl ^^), but...

If you run Electron v16 with ELECTRON_RUN_AS_NODE=1 env, it'll simply run the Node v16 runtime, just with a different ABI version tag

this not. Thanks for further explanation :+1:

ferminc commented 1 year ago

Just tried it with electron forge (vite template, electron@26.0.0 and better-sqlite3@8.5.1) and it's not working, everything works when I downgrade to electron@25.5.0 and better-sqlite3@8.5.0, anyone else having problems?

KillerCodeMonkey commented 1 year ago

Do you use the correct nodes version in your project?

Electron 26 is using node 18.16.1

https://www.electronjs.org/blog/electron-26-0

m4heshd commented 1 year ago

@ferminc It's possible that your native modules aren't properly rebuilt for the newer version of Electron you're using. Since you're using electron-forge, you need to run electron-rebuild to trigger a rebuild of native modules against the Electron version you're using.

KillerCodeMonkey commented 1 year ago

i can confirm everything is working with electron-builer, electron 26 and latest better-sqlite

linonetwo commented 1 year ago

Did you encounter https://github.com/electron/electron/issues/39600 in electron 26?

ferminc commented 1 year ago

This is the error I'm getting [6816:0821/172133.060:ERROR:crashpad_client_win.cc(844)] not connected with electron forge, steps to reproduce (I'm using windows 11):

So, maybe there's something going on with forge, I haven't tried using electron-builder

tianakack commented 12 months ago

This is the error I'm getting [6816:0821/172133.060:ERROR:crashpad_client_win.cc(844)] not connected with electron forge, steps to reproduce (I'm using windows 11):

  • yarn create electron-app my-new-app --template=vite
  • cd my-new-app
  • yarn add better-sqlite3
  • in src/main.js add: const db = require('better-sqlite3')('foobar.db'); db.pragma('journal_mode = WAL');
  • yarn start
  • remove electron and better-sqlite3, then yarn add electron@25.5.0 and yarn add better-sqlite3@8.5.0 to check that those versions still work

So, maybe there's something going on with forge, I haven't tried using electron-builder

I've also encountered this issue. Was your issue resolved? How it resolved?

ferminc commented 12 months ago

This is the error I'm getting [6816:0821/172133.060:ERROR:crashpad_client_win.cc(844)] not connected with electron forge, steps to reproduce (I'm using windows 11):

  • yarn create electron-app my-new-app --template=vite
  • cd my-new-app
  • yarn add better-sqlite3
  • in src/main.js add: const db = require('better-sqlite3')('foobar.db'); db.pragma('journal_mode = WAL');
  • yarn start
  • remove electron and better-sqlite3, then yarn add electron@25.5.0 and yarn add better-sqlite3@8.5.0 to check that those versions still work

So, maybe there's something going on with forge, I haven't tried using electron-builder

I've also encountered this issue. Was your issue resolved? How it resolved?

They haven't release a fix yet, but you can fix it yourself rebuilding manually: https://github.com/WiseLibs/better-sqlite3/issues/1044#issuecomment-1693735596

you'll need to have visual studio and python installed

jepiqueau commented 11 months ago

I got the same issue with @capacitor-community/sqlite which use better-sqlite3-multiple-ciphers for the Electron part of the plugin capacitor-community/sqlite-issue#474. The plugin work fine with Electron 25.8.4 and better-sqlite3-multiple-ciphers 8.4.0 but when i upgrade Electron to 26.1.0 it failed:

called ipcMain.handle: CapacitorSQLite-open
/Volumes/Development_Lacie/Development/ionic7/angular-sqlite-app-starter/electron/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGSEGV
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Electron [23496]
Path:                  /Volumes/VOLUME/*/Electron.app/Contents/MacOS/Electron
Identifier:            com.github.Electron
Version:               26.2.4 (26.2.4)
Code Type:             X86-64 (Native)
Parent Process:        node [23495]
Responsible:           Terminal [1462]
User ID:               501

Date/Time:             2023-10-01 11:50:01.7501 +0200
OS Version:            macOS 12.6.9 (21G726)
Report Version:        12
Bridge OS Version:     3.0 (14Y910)
Anonymous UUID:        F52BD279-4C53-B6B9-C38C-1439CFB5C8F0

Time Awake Since Boot: 19000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  CrBrowserMain  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000014078
Exception Codes:       0x0000000000000001, 0x0000000000014078
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [23496]

VM Region Info: 0x14078 is not in any region.  Bytes before following region: 4516044680
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      10d2ea000-10d2ec000    [    8K] r-x/r-x SM=COW  ...acOS/Electron

Thread 0 Crashed:: CrBrowserMain Dispatch queue: com.apple.main-thread
0   better_sqlite3.node                    0x11425bd6c Statement::JS_new(v8::FunctionCallbackInfo<v8::Value> const&) + 188
1   Electron Framework                     0x11fae5304 v8::internal::Accessors::MakeAccessor(v8::internal::Isolate*, v8::internal

my node version is v18.17.1