Blizzard / Blizzard/node-rdkafka

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

Open
#1,098 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.2k
Forks
403
PR merge metrics
No merged PRs in 30d

Description

**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 > > 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

https://github.com/WiseLibs/better-sqlite3/issues/1199#issuecomment-2160095895

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:

https://github.com/Blizzard/node-rdkafka/blob/8a3d40cee66a9ac5228d709959951a8f59d326a4/src/callbacks.h#L44

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

```
template using CopyablePersistent = v8::Persistent>;
template using CopyablePersistent = v8::Global;
```

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.

Contributor guide

Open the contributing guide

Research direction

Start with src/callbacks.h around the CopyablePersistent declaration and compare the Electron v27 and v28 rebuild failures shown in the report. Check how the V8 v12 change affects the native binding, then verify that node-rdkafka builds successfully with Electron v28 or newer using the reported setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, electron, node.js
Domain
build-system, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.