Skip to content

CreationContext is no longer supported #858

Closed

Description

@tazzben

For a few versions of Electron it has been warning that the CreationContext was depreciate (or more correctly depreciated in v8). With electron 20, the bundled version of tooling no longer supports CreationContext at all. This is what happens when you try to compile:

`Preparing native dependencies: 0 / 1./src/util/macros.lzz:157:21: error: no member named 'AccessorSignature' in namespace 'v8'
v8::AccessorSignature::New(isolate, recv)
~~~~^
⠸ Preparing native dependencies: 0 / 1./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::Localv8::Context ctx = obj->CreationContext();
~~~~~^
1 warning and 2 errors generated.

`

Environment:
Building an Electron app using Electron 20 on macOS ARM.

Activity

  1. quanglam2807 commented on Aug 5, 2022

    @quanglam2807

    Same issue for us after updating to Electron 20.x

    $ prebuild-install || npm run build-release
        
        > [email protected] build-release
        > node-gyp rebuild --release
        
          TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
          ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate
          TOUCH Release/obj.target/deps/locate_sqlite3.stamp
          CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
          LIBTOOL-STATIC Release/sqlite3.a
          CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
        rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
        
                        errorOut=prebuild-install warn install No prebuilt binaries found (target=20.0.1 runtime=electron arch=arm64 libc= platform=darwin)
        gyp info it worked if it ends with ok
        gyp info using [email protected]
        gyp info using [email protected] | darwin | arm64
        gyp info find Python using Python version 3.9.13 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
        gyp http GET https://electronjs.org/headers/v20.0.1/node-v20.0.1-headers.tar.gz
        gyp http 200 https://artifacts.electronjs.org/headers/dist/v20.0.1/node-v20.0.1-headers.tar.gz
        gyp http GET https://electronjs.org/headers/v20.0.1/SHASUMS256.txt
        gyp http 200 https://artifacts.electronjs.org/headers/dist/v20.0.1/SHASUMS256.txt
        gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
        gyp info spawn args [
        gyp info spawn args   '/Users/quanglam2807/.nvm/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
        gyp info spawn args   'binding.gyp',
        gyp info spawn args   '-f',
        gyp info spawn args   'make',
        gyp info spawn args   '-I',
        gyp info spawn args   '/Users/quanglam2807/Documents/GitHub/webcatalog/photon/node_modules/better-sqlite3/build/config.gypi',
        gyp info spawn args   '-I',
        gyp info spawn args   '/Users/quanglam2807/.nvm/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
        gyp info spawn args   '-I',
        gyp info spawn args   '/Users/quanglam2807/.electron-gyp/20.0.1/include/node/common.gypi',
        gyp info spawn args   '-Dlibrary=shared_library',
        gyp info spawn args   '-Dvisibility=default',
        gyp info spawn args   '-Dnode_root_dir=/Users/quanglam2807/.electron-gyp/20.0.1',
        gyp info spawn args   '-Dnode_gyp_dir=/Users/quanglam2807/.nvm/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp',
        gyp info spawn args   '-Dnode_lib_file=/Users/quanglam2807/.electron-gyp/20.0.1/<(target_arch)/node.lib',
        gyp info spawn args   '-Dmodule_root_dir=/Users/quanglam2807/Documents/GitHub/webcatalog/photon/node_modules/better-sqlite3',
        gyp info spawn args   '-Dnode_engine=v8',
        gyp info spawn args   '--depth=.',
        gyp info spawn args   '--no-parallel',
        gyp info spawn args   '--generator-output',
        gyp info spawn args   'build',
        gyp info spawn args   '-Goutput_dir=.'
        gyp info spawn args ]
        gyp info spawn make
        gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
        In file included from ../src/better_sqlite3.cpp:4:
        In file included from ./src/better_sqlite3.lzz:11:
        /Users/quanglam2807/.electron-gyp/20.0.1/include/node/node.h:27:2: error: "It looks like you are building this native module without using the right config.gypi.  This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly."
        #error "It looks like you are building this native module without using the right config.gypi.  This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly."
         ^
        In file included from ../src/better_sqlite3.cpp:4:
        In file included from ./src/better_sqlite3.lzz:11:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/node.h:69:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8.h:24:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8-array-buffer.h:13:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8-object.h:9:
        /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8-maybe.h:106:45: error: no template named 'is_lvalue_reference_v' in namespace 'std'; did you mean 'is_lvalue_reference'?
          template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
                                               ~~~~~^~~~~~~~~~~~~~~~~~~~~
                                                    is_lvalue_reference
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:910:29: note: 'is_lvalue_reference' declared here
        struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
                                    ^
        In file included from ../src/better_sqlite3.cpp:4:
        In file included from ./src/better_sqlite3.lzz:11:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/node.h:69:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8.h:24:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8-array-buffer.h:13:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8-object.h:9:
        /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8-maybe.h:106:69: error: expected '(' for function-style cast or type construction
          template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8-maybe.h:123:43: error: no template named 'is_lvalue_reference_v' in namespace 'std'; did you mean 'is_lvalue_reference'?
        template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
                                             ~~~~~^~~~~~~~~~~~~~~~~~~~~
                                                  is_lvalue_reference
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:910:29: note: 'is_lvalue_reference' declared here
        struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
                                    ^
        In file included from ../src/better_sqlite3.cpp:4:
        In file included from ./src/better_sqlite3.lzz:11:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/node.h:69:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8.h:24:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8-array-buffer.h:13:
        In file included from /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8-object.h:9:
        /Users/quanglam2807/.electron-gyp/20.0.1/include/node/v8-maybe.h:123:67: error: expected '(' for function-style cast or type construction
        template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        ./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();
                                                     ~~~~~^
        1 warning and 7 errors generated.
        make: *** [Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1
        gyp ERR! build error 
        gyp ERR! stack Error: `make` failed with exit code: 2
        gyp ERR! stack     at ChildProcess.onExit (/Users/quanglam2807/.nvm/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
        gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
        gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
        gyp ERR! System Darwin 21.5.0
        gyp ERR! command "/Users/quanglam2807/.nvm/versions/node/v16.14.0/bin/node" "/Users/quanglam2807/.nvm/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
        gyp ERR! cwd /Users/quanglam2807/Documents/GitHub/webcatalog/photon/node_modules/better-sqlite3
        gyp ERR! node -v v16.14.0
        gyp ERR! node-gyp -v v8.4.1
        gyp ERR! not ok 
        npm notice 
        npm notice New minor version of npm available! 8.4.1 -> 8.16.0
        npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.16.0>
        npm notice Run `npm install -g [email protected]` to update!
        npm notice 
    error Command failed with exit code 1.
        
                        command=/Users/quanglam2807/.nvm/versions/node/v16.14.0/bin/node /opt/homebrew/Cellar/yarn/1.22.19/libexec/bin/yarn.js run install
                        workingDir=/Users/quanglam2807/Documents/GitHub/webcatalog/photon/node_modules/better-sqlite3
    error Command failed with exit code 1.
    
  2. Prinzhorn commented on Aug 5, 2022

    @Prinzhorn
    Contributor

    I think the AccessorSignature error is an unrelated additional issue with Electron 20 electron/electron#35193

    Can anyone point to sources regarding CreationContext and the migration path?

    Edit: I also don't know if better-sqlite3 is affected by this https://www.electronjs.org/blog/v8-memory-cage ? E.g. if SQLite allocates memory for something like a BLOB, how is that transferred to the Node.js world? From what I can tell the data is already copied, so this should be correct?

    case SQLITE_BLOB: \
    return node::Buffer::Copy( \
    isolate, \
    static_cast<const char*>(sqlite3_##from##_blob(__VA_ARGS__)), \
    sqlite3_##from##_bytes(__VA_ARGS__) \
    ).ToLocalChecked(); \

  3. neoxpert commented on Aug 12, 2022

    @neoxpert
    Contributor

    Regarding CreationContext a Change to ->GetCreationContext().ToLocalChecked() should be suitable, but so far none of the suggested workarounds for AccessorSignature did work (for me).

  4. neoxpert commented on Aug 26, 2022

    @neoxpert
    Contributor

    It seems that there may also be an issue with the latest changes in the v8-callbacks.h header files when explicitly calling npx --no-install prebuild -r electron -t 20.0.0. After changing the definitions

    using LegacyOOMErrorCallback V8_DEPRECATE_SOON(
        "Use OOMErrorCallback (https://crbug.com/1323177)") =
        void (*)(const char* location, bool is_heap_oom);
    
    using WasmDynamicTieringEnabledCallback V8_DEPRECATE_SOON(
        "Dynamic tiering is now enabled by default") =
        bool (*)(Local<Context> context);
    

    to

    using LegacyOOMErrorCallback = void (*)(const char* location, bool is_heap_oom);
    using WasmDynamicTieringEnabledCallback = bool (*)(Local<Context> context);
    

    With some quick and dirty changes to the better-sqlite3 code by commenting out line 108 of better-sqlite3.cpp

                    v8::PropertyAttribute::None// ,
                    // v8::AccessorSignature::New(isolate, recv)
            );
    

    and changing the line 1952 in better-sqlite3.cpp from

    v8::Local<v8::Context> ctx = obj->CreationContext();
    

    to

    v8::Local<v8::Context> ctx = obj->GetCreationContext().ToLocalChecked();
    

    I was at least able to compile against electron 20.0.0 after also forcing rebuild to use node-gyp 8.4.1.

    Edit: Just found my changes to better-sqlite3.cpp partially correspond to signalapp/better-sqlite3@65d5e33

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions