new events.EventEmitterAsyncResource(options)
options
<Object>captureRejections
<boolean> 启用自动捕获 promise 拒绝。 默认值:false
。name
<string> 异步事件的类型。 默认值::new.target.name
。triggerAsyncId
<number> 创建此异步事件的执行上下文的 ID。 默认值:executionAsyncId()
。requireManualDestroy
<boolean> 如果设置为true
,则当对象被垃圾回收时禁用emitDestroy
。 这通常不需要设置(即使手动调用emitDestroy
),除非检索到资源的asyncId
并调用敏感 API 的emitDestroy
。 当设置为false
时,则只有在至少有一个活动的destroy
钩子时才会调用emitDestroy
垃圾回收。 默认值:false
。
options
<Object>captureRejections
<boolean> It enables automatic capturing of promise rejection. Default:false
.name
<string> The type of async event. Default::new.target.name
.triggerAsyncId
<number> The ID of the execution context that created this async event. Default:executionAsyncId()
.requireManualDestroy
<boolean> If set totrue
, disablesemitDestroy
when the object is garbage collected. This usually does not need to be set (even ifemitDestroy
is called manually), unless the resource'sasyncId
is retrieved and the sensitive API'semitDestroy
is called with it. When set tofalse
, theemitDestroy
call on garbage collection will only take place if there is at least one activedestroy
hook. Default:false
.