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 4, 2021
1 parent 9643128 commit c415460
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -795,10 +795,14 @@ 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 c415460

Please sign in to comment.