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 20 compatibility #867

Closed
kryops opened this issue Aug 24, 2022 · 8 comments · Fixed by #870
Closed

Electron 20 compatibility #867

kryops opened this issue Aug 24, 2022 · 8 comments · Fixed by #870

Comments

@kryops
Copy link

kryops commented Aug 24, 2022

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: #126 (comment)

Thanks for looking into it!

@kryops
Copy link
Author

kryops commented Aug 25, 2022

😳 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?

@cshotton
Copy link

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.

@122330602
Copy link

122330602 commented Sep 27, 2022

two months passed, electron V20 is still not supported

@cshotton
Copy link

cshotton commented Sep 28, 2022

two months passed, electron V20 is still not supported

FWIW you can npm install electron@19.0.10 and still get npx electron-rebuild -f -w better-sqlite3 to work as expected while we wait.

@mckravchyk
Copy link

mckravchyk commented Oct 13, 2022

You don't have to wait:

  1. Clone this PR fork to your machine
  2. Apply the C++17 fix if you need it (see PR comments)
  3. 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"
  4. Run npm install && npx electron-builder install-app-deps (you have to have electron-builder installed locally)

@cwellsx
Copy link

cwellsx commented Oct 23, 2022

You don't have to wait:

  1. Clone this PR fork to your machine
  2. Apply the C++17 fix if you need it (see PR comments)
  3. 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"
  4. 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

@linonetwo
Copy link

Solve electron25 build error nodejs/node#2341 (comment)

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

Successfully merging a pull request may close this issue.

8 participants