node_api_post_finalizer
functionexperimentaljs_native_api.hSchedules a napi_finalize callback to be called asynchronously in the event loop.
Stability: 1 - Experimental
napi_status node_api_post_finalizer(node_api_basic_env env,
napi_finalize finalize_cb,
void* finalize_data,
void* finalize_hint);
[in] env: The environment that the API is invoked under.[in] finalize_cb: Native callback that will be used to free the native data when the JavaScript object has been garbage-collected.napi_finalizeprovides more details.[in] finalize_data: Optional data to be passed tofinalize_cb.[in] finalize_hint: Optional contextual hint that is passed to the finalize callback.
Returns napi_ok if the API succeeded.
Schedules a napi_finalize callback to be called asynchronously in the
event loop.
Normally, finalizers are called while the GC (garbage collector) collects objects. At that point calling any Node-API that may cause changes in the GC state will be disabled and will crash Node.js.
node_api_post_finalizer helps to work around this limitation by allowing the
add-on to defer calls to such Node-APIs to a point in time outside of the GC
finalization.