Skip to content

Commit

Permalink
doc: clarify ObjectWrap weak ref behavior (#1155)
Browse files Browse the repository at this point in the history
Refs: nodejs/node#42461

We currently defer finalizer callbacks until the loop is idle.
Warn users that the weak reference on ObjectWraps
isn't guaranteed to be valid just because the object hasn't
been finalized (destructed) yet.
  • Loading branch information
wroy7860 committed Mar 31, 2022
1 parent 352a416 commit c976be4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/object_wrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ be directly invoked from JavaScript. The **wrap** word refers to a way of
grouping methods and state of the class because it will be necessary write
custom code to bridge each of your C++ class methods.

**Caution:** When the JavaScript object is garbage collected, the call to the
C++ destructor may be deferred until a later time. Within that period,
`Value()` will return an empty value.

## Example

```cpp
Expand Down

0 comments on commit c976be4

Please sign in to comment.