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.