然后在asyncwork的execute函数中使用tsfn调用napi_call_threadsafe_function, 但传进CallJs函数的js_cb为0x0,怀疑是被GC了。 workaround方法是,在使用napi_get_cb_info得到js的callback函数地址value后封装成napi_ref,再通过context方式送入CallJs函数,再提取ref
When creating a node-addon-apiTSFN, you donotspecify acall_js_cbparameter like you do in underlyingnapi_create_threadsafe_function. Instead, this is passed as the optionalCallbackparameter in the[Non]BlockingCallmethod. (In theTSFNwrapper,this functionis used, and the optionalCallbackandDataare...