Skip to content

Commit

Permalink
doc: clarify the behaviour of asyncResource.emitDestroy()
Browse files Browse the repository at this point in the history
This updates the documentation of asyncResource.emitDestroy() to match
the usage of `requireManualDestroy` option.

Refs: nodejs#32409
  • Loading branch information
deepal committed May 3, 2021
1 parent 18e4f40 commit 21b624c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -795,10 +795,9 @@ then restore the original execution context.

* Returns: {AsyncResource} A reference to `asyncResource`.

Call all `destroy` hooks. This should only ever be called once. An error will
be thrown if it is called more than once. This **must** be manually called. If
the resource is left to be collected by the GC then the `destroy` hooks will
never be called.
Call all `destroy` hooks. This should only ever be called once to avoid `destroy` hooks being called multiple times. If `requireManualDestroy` is set to `false` (default value), this will be called on garbage collection automatically.

If `requireManualDestroy` option is set to `true` when the resource was constructed, this **must** be manually called. Otherwise, if the resource is left to be collected by the GC then the `destroy` hooks will never be called.

#### `asyncResource.asyncId()`

Expand Down

0 comments on commit 21b624c

Please sign in to comment.