- Assertion testing
- Asynchronous context tracking
- Async hooks
- Buffer
- C++ addons
- C/C++ addons with Node-API
- C++ embedder API
- Child processes
- Cluster
- Command-line options
- Console
- Corepack
- Crypto
- Debugger
- Deprecated APIs
- Diagnostics Channel
- DNS
- Domain
- Errors
- Events
- File system
- Globals
- HTTP
- HTTP/2
- HTTPS
- Inspector
- Internationalization
- Modules: CommonJS modules
- Modules: ECMAScript modules
- Modules:
node:module
API - Modules: Packages
- Net
- OS
- Path
- Performance hooks
- Permissions
- Process
- Punycode
- Query strings
- Readline
- REPL
- Report
- Stream
- String decoder
- Test runner
- Timers
- TLS/SSL
- Trace events
- TTY
- UDP/datagram
- URL
- Utilities
- V8
- VM
- WASI
- Web Crypto API
- Web Streams API
- Worker threads
- Zlib
Node.js v18.12.1 documentation
- Node.js v18.12.1
- ► Table of contents
-
► Index
- Assertion testing
- Asynchronous context tracking
- Async hooks
- Buffer
- C++ addons
- C/C++ addons with Node-API
- C++ embedder API
- Child processes
- Cluster
- Command-line options
- Console
- Corepack
- Crypto
- Debugger
- Deprecated APIs
- Diagnostics Channel
- DNS
- Domain
- Errors
- Events
- File system
- Globals
- HTTP
- HTTP/2
- HTTPS
- Inspector
- Internationalization
- Modules: CommonJS modules
- Modules: ECMAScript modules
- Modules:
node:module
API - Modules: Packages
- Net
- OS
- Path
- Performance hooks
- Permissions
- Process
- Punycode
- Query strings
- Readline
- REPL
- Report
- Stream
- String decoder
- Test runner
- Timers
- TLS/SSL
- Trace events
- TTY
- UDP/datagram
- URL
- Utilities
- V8
- VM
- WASI
- Web Crypto API
- Web Streams API
- Worker threads
- Zlib
- ► Other versions
- ► Options
Table of contents
Domain#
Source Code: lib/domain.js
This module is pending deprecation.此模块正在等待弃用。 Once a replacement API has been finalized, this module will be fully deprecated. 一旦完成替换API,此模块将被完全弃用。Most developers should not have cause to use this module. 大多数开发人员应该没有理由使用此模块。Users who absolutely must have the functionality that domains provide may rely on it for the time being but should expect to have to migrate to a different solution in the future.绝对必须拥有域提供的功能的用户可能暂时依赖它,但将来应该需要迁移到不同的解决方案。
Domains provide a way to handle multiple different IO operations as a single group. 域提供了一种将多个不同IO操作作为单个组处理的方法。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.'error'
事件或抛出错误,则将通知域对象,而不是在process.on('uncaughtException')
处理程序中丢失错误上下文,或导致程序立即退出并返回错误代码。