【Domain】

稳定性: 0 - 已弃用

源代码: lib/domain.js

此模块正在等待弃用。 一旦替代的 API 确定,该模块将被完全弃用。大多数开发者需要使用此模块。那些确实需要域提供的功能的用户可以暂时依赖它,但将来应预计需要迁移到其他解决方案。

域提供了一种将多个不同的 IO 操作作为单个组来处理的方法。如果注册到域的任何事件触发器或回调发出 'error' 事件,或抛出错误,则域对象将被通知,而不是在 process.on('uncaughtException') 处理程序中丢失错误的上下文,或导致程序立即以错误代码退出。

【Domains provide a way to handle multiple different IO operations as a single group. If any of the event emitters or callbacks registered to a domain emit an 'error' event, or throw an error, then the domain object will be notified, rather than losing the context of the error in the process.on('uncaughtException') handler, or causing the program to exit immediately with an error code.】