Electron 20 compatibility
Hi there,
when upgrading to Electron 20, better-sqlite3 does not build any longer.
On macOS, I get the following error:
CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
./src/util/macros.lzz:157:21: error: no member named 'AccessorSignature' in namespace 'v8'
v8::AccessorSignature::New(isolate, recv)
~~~~^
./src/objects/database.lzz:180:21: warning: variable 'status' set but not used [-Wunused-but-set-variable]
int status = sqlite3_db_config(db_handle, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, NULL);
^
./src/util/binder.lzz:37:51: error: no member named 'CreationContext' in 'v8::Object'
v8::Local<v8::Context> ctx = obj->CreationContext();
~~~~~^
On Windows (using Visual Studio 2017), I get the following:
c:\users\...\.electron-gyp\20.0.3\include\node\v8-callbacks.h(221): error C2062: type 'int' unexpected
c:\users\...\.electron-gyp\20.0.3\include\node\v8-callbacks.h(335): error C2062: type 'int' unexpected
c:\users\...\.electron-gyp\20.0.3\include\node\v8-isolate.h(292): error C3646: 'legacy_oom_error_callback': unknown override specifier
c:\users\...\.electron-gyp\20.0.3\include\node\v8-isolate.h(292): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\...\.electron-gyp\20.0.3\include\node\v8-isolate.h(1482): error C2061: syntax error: identifier 'LegacyOOMErrorCallback'
c:\users\...\.electron-gyp\20.0.3\include\node\v8-isolate.h(1545): error C2061: syntax error: identifier 'WasmDynamicTieringEnabledCallback'
c:\users\...\.electron-gyp\20.0.3\include\node\v8-initialization.h(290): error C2061: syntax error: identifier 'LegacyOOMErrorCallback'
c:\...\node_modules\better-sqlite3\build\src\objects\database.lzz(453): warning C4309: 'static_cast': truncation of constant value
c:\...\node_modules\better-sqlite3\build\src\util\macros.lzz(157): error C2039: 'AccessorSignature': is not a member of 'v8'
c:\users\...\.electron-gyp\20.0.3\include\node\v8.h(71): note: see declaration of 'v8'
c:\...\node_modules\better-sqlite3\build\src\util\macros.lzz(157): error C3083: 'AccessorSignature': the symbol to the left of a '::' must be a type
c:\...\node_modules\better-sqlite3\build\src\util\macros.lzz(157): error C2039: 'New': is not a member of 'v8'
c:\users\...\.electron-gyp\20.0.3\include\node\v8.h(71): note: see declaration of 'v8'
c:\...\node_modules\better-sqlite3\build\src\util\macros.lzz(157): error C3861: 'New': identifier not found
c:\...\node_modules\better-sqlite3\build\src\util\binder.lzz(37): error C2039: 'CreationContext': is not a member of 'v8::Object'
C:\Users\...\.electron-gyp\20.0.3\include\node\v8-value-serializer.h(21): message : see declaration of 'v8::Object'
On Windows (using the Visual Studio 2022 Build Tools):
C:\Users\...\.electron-gyp\20.0.3\include\node\v8-isolate.h(292,5): warning C4996: 'v8::LegacyOOMErrorCallback': Use OOMErrorCallback (https://crbug.com/1323177)
C:\Users\...\.electron-gyp\20.0.3\include\node\v8-isolate.h(1482,27): warning C4996: 'v8::LegacyOOMErrorCallback': Use OOMErrorCallback (https://crbug.com/1323177)
C:\Users\...\.electron-gyp\20.0.3\include\node\v8-isolate.h(1545,45): warning C4996: 'v8::WasmDynamicTieringEnabledCallback': Dynamic tiering is now enabled by default
C:\Users\...\.electron-gyp\20.0.3\include\node\v8-initialization.h(290,43): warning C4996: 'v8::LegacyOOMErrorCallback': Use OOMErrorCallback (https://crbug.com/1323177)
C:\...\node_modules\better-sqlite3\build\src\util\macros.lzz(157,21): error C2039: 'AccessorSignature': is not a member of 'v8'
C:\Users\...\.electron-gyp\20.0.3\include\node\v8.h(71): message : see declaration of 'v8'
C:\...\node_modules\better-sqlite3\build\src\util\macros.lzz(157,21): error C3083: 'AccessorSignature': the symbol to the left of a '::' must be a type
C:\...\node_modules\better-sqlite3\build\src\util\macros.lzz(157,40): error C2039: 'New': is not a member of 'v8'
C:\Users\...\.electron-gyp\20.0.3\include\node\v8.h(71): message : see declaration of 'v8'
C:\...\node_modules\better-sqlite3\build\src\util\macros.lzz(157,43): error C3861: 'New': identifier not found
C:\...\node_modules\better-sqlite3\build\src\util\binder.lzz(37,51): error C2039: 'CreationContext': is not a member of 'v8::Object'
C:\Users\...\.electron-gyp\20.0.3\include\node\v8-value-serializer.h(21): message : see declaration of 'v8::Object'
Related: https://github.com/WiseLibs/better-sqlite3/issues/126#issuecomment-1204957779
Thanks for looking into it!
https://github.com/WiseLibs/better-sqlite3/issues/858
https://github.com/WiseLibs/better-sqlite3/search?q=CreationContext&type=issues https://github.com/WiseLibs/better-sqlite3/search?q=AccessorSignature&type=issues
😳 my bad, somehow I did not find the existing issue. Should we close this one then, or leave it open for better "Electron 20" visibility?
Is there a prognosis for when the next release might be that will include this pull request? It'd be great to get Electron builds working again.
two months passed, electron V20 is still not supported
two months passed, electron V20 is still not supported
FWIW you can npm install [email protected] and still get npx electron-rebuild -f -w better-sqlite3 to work as expected while we wait.
You don't have to wait:
- Clone this PR fork to your machine
- Apply the C++17 fix if you need it (see PR comments)
- Reference the local fork in package.json with the path to the fork instead of the version number, i.e. "better-sqlite3": "file:../npm/better-sqlite3-electron-v21"
- Run
npm install && npx electron-builder install-app-deps(you have to have electron-builder installed locally)
You don't have to wait:
- Clone this PR fork to your machine
- Apply the C++17 fix if you need it (see PR comments)
- Reference the local fork in package.json with the path to the fork instead of the version number, i.e. "better-sqlite3": "file:../npm/better-sqlite3-electron-v21"
- Run
npm install && npx electron-builder install-app-deps(you have to have electron-builder installed locally)
Thanks!
Though instead of doing a local install, i.e. of file:, I found it better to install the released version of better-sqlite3 and then overwrite that in my project's node_modules i.e. by copying the PR on top of the released version.
The local install didn't work so well with Webpack and Packaging.
Or there's now a comment in the pull thread saying,
For anyone else waiting on the merge, you should be able to install with:
npm install WiseLibs/better-sqlite3#pull/870/head
Solve electron25 build error https://github.com/nodejs/node/issues/2341#issuecomment-1579929170