Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: clarify napi_finalize behavior #42461

Merged
merged 2 commits into from
Mar 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5123,6 +5123,12 @@ invocation. If it is deleted before then, then the finalize callback may never
be invoked. Therefore, when obtaining a reference a finalize callback is also
required in order to enable correct disposal of the reference.

_Caution_: Finalizer callbacks may be deferred, leaving a window where the
mildsunrise marked this conversation as resolved.
Show resolved Hide resolved
object has been garbage collected (and the weak reference is invalid) but
the finalizer hasn't been called yet. When using `napi_get_reference_value`
on weak references returned by `napi_wrap()`, you should still handle an
empty result.

Calling `napi_wrap()` a second time on an object will return an error. To
associate another native instance with the object, use `napi_remove_wrap()`
first.
Expand Down