Skip to content

error C2039: 'Holder': is not a member of 'v8::FunctionCallbackInfo<v8::Value>' when using electron 36.0.0-beta.4 #996

Open
@oalfroukh

Description

@oalfroukh

Hi team,

  • We're encountering a breaking issue when building native modules using nan@2.22.2 in combination with Electron v36.0.0-beta.4.

  • The issue arises due to the use of info.Holder() in nan_callbacks_12_inl.h(112,62) In newer versions of V8, particularly as used in Electron 36, info.Holder() is not a valid member of FunctionCallbackInfo. This results in the following build error:

electron-quick-start-main-v36\node_modules\nan\nan_callbacks_12_inl.h(112,62): error C2039: 'Holder': is not a member of        
'v8::FunctionCallbackInfo<v8::Value>' [electron-quick-start-main-v36\native\test\build\test.vcxproj]
  • Code Context:
    In our code, we had this pattern:
 obj->Wrap(info.Holder());
 info.GetReturnValue().Set(info.Holder());
  • Minimal Repro:

Here's a simplified example that fails on Electron 36:

#include <nan.h>

class Dummy : public Nan::ObjectWrap {
public:
  static NAN_MODULE_INIT(Init) {
    v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
    tpl->SetClassName(Nan::New("Dummy").ToLocalChecked());
    tpl->InstanceTemplate()->SetInternalFieldCount(1);

    constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
    Nan::Set(target, Nan::New("Dummy").ToLocalChecked(),
             Nan::GetFunction(tpl).ToLocalChecked());
  }

private:
  explicit Dummy() {}
  ~Dummy() {}

  static NAN_METHOD(New) {
    if (info.IsConstructCall()) {
      Dummy* obj = new Dummy();
      obj->Wrap(info.Holder());  // <-- ❌ This will cause the issue
      info.GetReturnValue().Set(info.Holder());
    }
  }

  static inline Nan::Persistent<v8::Function>& constructor() {
    static Nan::Persistent<v8::Function> my_constructor;
    return my_constructor;
  }
};

NAN_MODULE_INIT(InitAll) {
  Dummy::Init(target);
}

NODE_MODULE(addon, InitAll)

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