@@ -5424,6 +5424,42 @@ invocation. If it is deleted before then, then the finalize callback may never
54245424be invoked. Therefore, when obtaining a reference a finalize callback is also
54255425required in order to enable correct disposal of the reference.
54265426
5427+ #### `node_api_post_finalizer`
5428+
5429+ <!-- YAML
5430+ added: REPLACEME
5431+ -->
5432+
5433+ > Stability: 1 - Experimental
5434+
5435+ ```c
5436+ napi_status node_api_post_finalizer(napi_env env,
5437+ napi_finalize finalize_cb,
5438+ void* finalize_data,
5439+ void* finalize_hint);
5440+ ```
5441+
5442+ * `[in] env`: The environment that the API is invoked under.
5443+ * `[in] finalize_cb`: Native callback that will be used to free the
5444+ native data when the JavaScript object has been garbage-collected.
5445+ [`napi_finalize`][] provides more details.
5446+ * `[in] finalize_data`: Optional data to be passed to `finalize_cb`.
5447+ * `[in] finalize_hint`: Optional contextual hint that is passed to the
5448+ finalize callback.
5449+
5450+ Returns `napi_ok` if the API succeeded.
5451+
5452+ Schedules a `napi_finalize` callback to be called asynchronously in the
5453+ event loop.
5454+
5455+ Normally, finalizers are called while the GC (garbage collector) collects
5456+ objects. At that point calling any Node-API that may cause changes in the GC
5457+ state will be disabled and will crash Node.js.
5458+
5459+ `node_api_post_finalizer` helps to work around this limitation by allowing the
5460+ add-on to defer calls to such Node-APIs to a point in time outside of the GC
5461+ finalization.
5462+
54275463## Simple asynchronous operations
54285464
54295465Addon modules often need to leverage async helpers from libuv as part of their
0 commit comments