Expand description
Node domain module (deprecated in Node, implemented here with its real
error-trapping semantics). A Domain is an EventEmitter (same @@native +
@@on/@@once shape as events/net) whose defining behaviour is
domain.run(fn): it runs fn and, if fn throws, emits the domain’s
'error' event with the thrown value instead of propagating the throw.
Scope of the port: .run/.bind/.intercept genuinely trap synchronous
throws from the function they wrap and route them to 'error'. What is NOT
wired is Node’s implicit interception of errors emitted by emitters passed
to .add() — node-js has no per-emitter active-domain hook, so .add()/
.remove() only track membership (best-effort) and do not auto-forward those
emitters’ 'error' events. Only code run through .run/.bind/.intercept
is actually protected. .enter()/.exit() maintain a thread-local domain
stack whose top is exposed as domain.active.
Constants§
- DOMAIN_
METHODS - Instance methods carried by a
Domainbeyond the shared EventEmitter surface (whichinstance_has_methodadds via the emitter set). - METHODS
- Module-level methods (
require('domain').create()).
Functions§
- call
require('domain')module dispatch.- constant
domain.active— the current (top-of-stack) domain, ornull.- construct
new domain.Domain()(Node prefersdomain.create(), but the constructor exists).- instance_
call - new_
domain - A fresh
Domain(emitter object tagged"Domain"), carrying a hidden@@membersarray for.add/.removebookkeeping.