type
type
是字符串,标识导致调用 init
的资源类型。一般会对应资源的构造函数名。
¥The type
is a string identifying the type of resource that caused
init
to be called. Generally, it will correspond to the name of the
resource's constructor.
有效值为:
¥Valid values are:
FSEVENTWRAP, FSREQCALLBACK, GETADDRINFOREQWRAP, GETNAMEINFOREQWRAP, HTTPINCOMINGMESSAGE,
HTTPCLIENTREQUEST, JSSTREAM, PIPECONNECTWRAP, PIPEWRAP, PROCESSWRAP, QUERYWRAP,
SHUTDOWNWRAP, SIGNALWRAP, STATWATCHER, TCPCONNECTWRAP, TCPSERVERWRAP, TCPWRAP,
TTYWRAP, UDPSENDWRAP, UDPWRAP, WRITEWRAP, ZLIB, SSLCONNECTION, PBKDF2REQUEST,
RANDOMBYTESREQUEST, TLSWRAP, Microtask, Timeout, Immediate, TickObject
这些值可以在任何 Node.js 版本中更改。此外,AsyncResource
的用户可能会提供其他值。
¥These values can change in any Node.js release. Furthermore users of AsyncResource
likely provide other values.
还有 PROMISE
资源类型,用于跟踪 Promise
实例以及它们调度的异步工作。
¥There is also the PROMISE
resource type, which is used to track Promise
instances and asynchronous work scheduled by them.
用户可以在使用公共嵌入器 API 时定义自己的 type
。
¥Users are able to define their own type
when using the public embedder API.
可能存在类型名称冲突。鼓励嵌入器使用唯一的前缀,例如 npm 包名,以防止在监听钩子时发生冲突。
¥It is possible to have type name collisions. Embedders are encouraged to use unique prefixes, such as the npm package name, to prevent collisions when listening to the hooks.