-
-
Notifications
You must be signed in to change notification settings - Fork 526
Open
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
Labels
No labels