انتقل إلى المحتوى

لم تُترجم هذه الصفحة بعد، لذا تُعرض بالإنجليزية.

node:domain

How Elide supports Node's deprecated domain module: create(), run() and the error event for synchronous and timer errors, and what to use instead.

اقرأ دون اتصالelide help api-node-domain

في هذه الصفحة
الاستخدام مع الذكاء الاصطناعي
افتح في ChatGPTافتح في Claudeالاتصال عبر MCP

node:domain exports Domain, create(), createDomain(), and active from Node’s deprecated domain. Synchronous and timer errors thrown inside run() go to the domain’s error event. Use Promise and EventEmitter error handling in new code.

Example

js
// domain.mjs
import domain from "node:domain";

const d = domain.create();
d.on("error", (error) => console.log("caught:", error.message));
d.run(() => {
  setTimeout(() => {
    throw new Error("timer failed");
  }, 1);
});
utf-8 · js · Lines: 10

elide run domain.mjs prints:

text
caught: timer failed
utf-8 · text · Lines: 1

Reference

Status: Full · Not measured

domain exports

Domain, active, create, createDomain

هل كانت هذه الصفحة مفيدة؟