You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a native module that's throwing an error, but only when running in the node console, not in a script. This makes me think I have a C++ instance lifetime issue, but I can't see anything obvious, and similar code in other places is behaving fine.
I've boiled the issue down to this small example. A C++ ObjectWrap instantiates and holds a reference to another ObjectWrap instance. Later, the outer ObjectWrap instance delegates various behavior to the inner instance.
Below is my attempt to replicate the above in C++, but I'm seeing this error in the node console. It looks like there's an initial error being thrown, but then another error constructing the Napi::Error, leading to the abort:
But if I run it in a script, I don't get any errors:
// test.jsconst{ Parent }=require('./build/addon.node');constp=newParent();console.log('p.value:',p.value);console.log('p.child.value:',p.child.value);// Give the GC time to sweep before accessing againsetTimeout(()=>console.log('p.value:',p.value),1000);/*$ node test.jsp.value: 5p.child.value: 5p.value: 5*/
The text was updated successfully, but these errors were encountered:
trxcllnt
changed the title
Error using ObjectWrap ObjectReference in node console
Error using ObjectReference to ObjectWrap in node console
Jan 5, 2021
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
I have a native module that's throwing an error, but only when running in the node console, not in a script. This makes me think I have a C++ instance lifetime issue, but I can't see anything obvious, and similar code in other places is behaving fine.
I've boiled the issue down to this small example. A C++ ObjectWrap instantiates and holds a reference to another ObjectWrap instance. Later, the outer ObjectWrap instance delegates various behavior to the inner instance.
Here's the example in JS:
Below is my attempt to replicate the above in C++, but I'm seeing this error in the node console. It looks like there's an initial error being thrown, but then another error constructing the Napi::Error, leading to the abort:
But if I run it in a script, I don't get any errors:
The C++:
Any ideas what could be going wrong here?
The text was updated successfully, but these errors were encountered: