node:domain API Reference

Deprecated Node domain compatibility

node:domain is deprecated in Node. Prefer explicit Promise and EventEmitter error handling in new code.

Elide exports Domain, create(), createDomain(), and active. Basic synchronous error routing works:

import domain from "node:domain";

const scope = domain.create();
scope.on("error", (error) => console.log(error.message));
scope.run(() => {
  throw new Error("boom");
});
// boom

The class exposes run, bind, intercept, enter, exit, and the EventEmitter surface. Compatibility for complex asynchronous domain flows is not guaranteed.