Skip to content

Unable to use node-rdkafka when updating Electron >=v28.0.0 due to V8 Engine v12 dependency #1098

@uncvrd

Description

@uncvrd

Environment Information

  • OS [e.g. Mac, Arch, Windows 10]: Mac, arm64 (M3)
  • Node Version [e.g. 8.2.1]: v18.18.2
  • NPM Version [e.g. 5.4.2]: v9.8.1
  • node-rdkafka version [e.g. 2.3.3]: 3.1.1

Steps to Reproduce

Hi there! I've been working on updating an existing project to a new set of dependencies. We currently use node-rdkafka in an Electron app running Electron v10. In an attempt to update to the version v28, this failed when Electron tries to build native dependencies (like node-rdkafka).

This has to do from an update of Electron that updates the V8 Engine from v11 to v12 and deprecates a function(?) called CopyablePersistentTraits

Here is the output i see:

/Users/lewallen/GitHub/plotter/node_modules/node-rdkafka/src/callbacks.h:45:44: error: no template named 'CopyablePersistentTraits' in namespace 'v8'; did you mean 'Nan::CopyablePersistentTraits'?
   45 |   std::vector<v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function> > > callbacks;  // NOLINT
      |                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                            Nan::CopyablePersistentTraits
../node_modules/nan/nan.h:208:29: note: 'Nan::CopyablePersistentTraits' declared here

I found something similar for sqlite here that mentions this deprecation

WiseLibs/better-sqlite3#1199 (comment)

When I install Electron v27 it uses V8 engine v11 and the @electron/rebuild build step succeeds but when I try to use Electron v28 it uses V8 engine v12 and it fails.

I am not an expert here, but am I on the right track that this is the culprit? I was wondering what steps would need to be taken to allow support for newer versions of the V8 engine that Electron uses >= v28

I see that this CopyablePerisistentTraits is utilized here:

protected:

Is it as simple as updating the function(?) to just do the following diff?

template <class T> using CopyablePersistent = v8::Persistent<T, v8::CopyablePersistentTraits<T>>;
template <class T> using CopyablePersistent = v8::Global<T>;

I do apologize for my lack of skill here but I'm hoping this can help lead us in the right direction for support of newer versions of Electron.

Really appreciate your time and let me know what else I can do to help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions