Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

NAN_GETTER and NAN_SETTER not called in Node 23+ #1006

Open
@FranciscoCano

Description

Hello!

I have a NAN_SETTER declared like:

.h

 static NAN_SETTER(SessionConnectedSetter);

.cpp

NAN_SETTER(MyClass::SessionConnectedSetter) {
 printf("MyClass::SessionConnectedSetter 0\n");
 MyClass *obj = ObjectWrap::Unwrap<MyClass>(info.This());
 printf("OTKSession::SessionConnectedSetter 1\n");
 Local<Function> cb = value.As<Function>();
 printf("OTKSession::SessionConnectedSetter 2\n");
 obj->session_connected_callback_ = new Nan::Callback(cb);
 printf("OTKSession::SessionConnectedSetter 3\n");
}
// Inside the Init function:
...
 Local<FunctionTemplate> ctor = Nan::New<FunctionTemplate>(MyClass::New);
 ctor->SetClassName(Nan::New("MyClass").ToLocalChecked());
 ctor->InstanceTemplate()->SetInternalFieldCount(1);
 constructor.Reset(ctor);
 printf("MyClass::Init 2\n");
 // Methods
 Local<ObjectTemplate> proto = ctor->PrototypeTemplate();
 Nan::SetAccessor(proto, Nan::New("onConnected").ToLocalChecked(), nullptr, SessionConnectedSetter);
...

And, I call the setter from Javascript:

const myObject = new MyClass();
myObject.onConnected = () => {
 console.log('onConnected Called!');
}

Expected
When the onConnected setter is set, I would expect the following output:

MyClass::SessionConnectedSetter 0
MyClass::SessionConnectedSetter 1
MyClass::SessionConnectedSetter 2
MyClass::SessionConnectedSetter 3

Actual
The Setter is never called and there are no logs in the output.
The same behaviour is seen with NAN_GETTER.

This works for node versions <= 22.

Can anyone please shed a bit of light here?
Thank you very much in advance!

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

        AltStyle によって変換されたページ (->オリジナル) /