EventTarget 错误处理
¥EventTarget error handling
当注册的事件监听器抛出错误(或返回拒绝的 Promise)时,默认情况下,错误将被视为 process.nextTick() 上的未捕获异常。这意味着 EventTarget 中未捕获的异常将默认终止 Node.js 进程。
¥When a registered event listener throws (or returns a Promise that rejects),
by default the error is treated as an uncaught exception on
process.nextTick(). This means uncaught exceptions in EventTargets will
terminate the Node.js process by default.
在事件监听器中抛出不会阻止调用其他已注册的处理程序。
¥Throwing within an event listener will not stop the other registered handlers from being invoked.
EventTarget 没有为 'error' 类型的事件(如 EventEmitter)实现任何特殊的默认处理。
¥The EventTarget does not implement any special default handling for 'error'
type events like EventEmitter.
当前错误在到达 process.on('uncaughtException') 之前首先转发到 process.on('error') 事件。此行为已弃用,并将在未来版本中更改,以使 EventTarget 与其他 Node.js API 保持一致。任何依赖 process.on('error') 事件的代码都应与新行为保持一致。
¥Currently errors are first forwarded to the process.on('error') event
before reaching process.on('uncaughtException'). This behavior is
deprecated and will change in a future release to align EventTarget with
other Node.js APIs. Any code relying on the process.on('error') event should
be aligned with the new behavior.