Skip to content

Confusing Documentation on asyncResource.emitDestroy() #32409

Closed
@deepal

Description

@deepal
  • Version: 13.x
  • Platform: N/A
  • Subsystem: Documentation

Additional information

The behaviour of asyncResource.emitDestroy() under async_hooks is somewhat confusing.

Documentation of the options.requireManualDestroy constructor argument property of AsyncResource states that:

(requireManualDestroy: true) Disables automatic emitDestroy when the object is garbage collected. This usually does not need to be set (even if emitDestroy is called manually), unless the resource's asyncId is retrieved and the sensitive API's emitDestroy is called with it. Default: false.

This indicates that asyncResource.emitDestroy() is automatically called by default. However, the following section on emitDestroy() documentation states that:

This must be manually called. If the resource is left to be collected by the GC then the destroy hooks will never be called.

I'm a bit confused about this. Shouldn't this be re-worded in order to convey behaviour of emitDestroy clearly?

PS: I was wondering whether I should create this issue on help repository, but have a feeling that the documentation might have to be amended. Therefore created the issue here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions