From 6ae58dd2ae5949e03f1ec1bafff687644b97db81 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Thu, 6 Aug 2026 08:48:08 +0000 Subject: [PATCH] domain: runtime-deprecate the module Promote DEP0032 from a documentation-only deprecation to a runtime deprecation. Loading the `node:domain` module now emits a DeprecationWarning with code DEP0032, and the docs are updated to reflect the Runtime deprecation type. Signed-off-by: Matteo Collina --- doc/api/deprecations.md | 8 ++++++-- doc/api/domain.md | 15 +++++++++------ lib/domain.js | 8 +++++++- test/parallel/test-domain-deprecation.js | 12 ++++++++++++ test/parallel/test-domain-http-server.js | 2 ++ test/parallel/test-domain-implicit-binding.js | 2 ++ test/parallel/test-domain-implicit-fs.js | 2 ++ test/parallel/test-domain-multi.js | 2 ++ test/parallel/test-domain-promise.js | 2 ++ 9 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 test/parallel/test-domain-deprecation.js diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 0868f0fae4c1..f7818c3e6038 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -774,6 +774,9 @@ the API is not useful. -Type: Documentation-only +Type: Runtime -The [`domain`][] module is deprecated and should not be used. +The [`domain`][] module is deprecated and should not be used. Loading the +module emits a runtime deprecation warning. ### DEP0033: `EventEmitter.listenerCount()` diff --git a/doc/api/domain.md b/doc/api/domain.md index 4838d4d4a7ef..af0613e16b9a 100644 --- a/doc/api/domain.md +++ b/doc/api/domain.md @@ -3,6 +3,10 @@ -**This module is pending deprecation.** Once a replacement API has been -finalized, this module will be fully deprecated. 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. +**This module is deprecated and should not be used.** Loading the module emits +a runtime deprecation warning (`DEP0032`). 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. If any of the event emitters or callbacks registered to a diff --git a/lib/domain.js b/lib/domain.js index cbd2b2bcd9b0..caf97983b8f8 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -21,8 +21,9 @@ 'use strict'; -// WARNING: THIS MODULE IS PENDING DEPRECATION. +// WARNING: THIS MODULE IS DEPRECATED (DEP0032). // +// Loading this module emits a runtime deprecation warning. // No new pull requests targeting this module will be accepted // unless they address existing, critical bugs. @@ -44,6 +45,11 @@ const { ERR_UNHANDLED_ERROR, } = require('internal/errors').codes; +// The `domain` module is deprecated (DEP0032). Emit a runtime deprecation +// warning when the module is loaded. +process.emitWarning('The `domain` module is deprecated and should not be used.', + 'DeprecationWarning', 'DEP0032'); + // Use AsyncLocalStorage for domain context propagation // Lazy initialization - ALS is created on first domain use let domainStorage; diff --git a/test/parallel/test-domain-deprecation.js b/test/parallel/test-domain-deprecation.js new file mode 100644 index 000000000000..48b4df6b238f --- /dev/null +++ b/test/parallel/test-domain-deprecation.js @@ -0,0 +1,12 @@ +'use strict'; +const common = require('../common'); + +const domainWarning = + 'The `domain` module is deprecated and should not be used.'; +common.expectWarning('DeprecationWarning', domainWarning, 'DEP0032'); + +const domain = require('domain'); +const assert = require('assert'); + +assert.strictEqual(typeof domain.create, 'function'); +assert.strictEqual(typeof domain.Domain, 'function'); diff --git a/test/parallel/test-domain-http-server.js b/test/parallel/test-domain-http-server.js index 160241d569b1..6555a58f305e 100644 --- a/test/parallel/test-domain-http-server.js +++ b/test/parallel/test-domain-http-server.js @@ -1,3 +1,5 @@ +// Flags: --no-deprecation + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a diff --git a/test/parallel/test-domain-implicit-binding.js b/test/parallel/test-domain-implicit-binding.js index 9f119a420368..84c140a1d77e 100644 --- a/test/parallel/test-domain-implicit-binding.js +++ b/test/parallel/test-domain-implicit-binding.js @@ -1,3 +1,5 @@ +// Flags: --no-deprecation + 'use strict'; const common = require('../common'); diff --git a/test/parallel/test-domain-implicit-fs.js b/test/parallel/test-domain-implicit-fs.js index abb4e89f085d..6e3a1cf68ab4 100644 --- a/test/parallel/test-domain-implicit-fs.js +++ b/test/parallel/test-domain-implicit-fs.js @@ -1,3 +1,5 @@ +// Flags: --no-deprecation + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a diff --git a/test/parallel/test-domain-multi.js b/test/parallel/test-domain-multi.js index 635208acac3c..6dc470e4bf4a 100644 --- a/test/parallel/test-domain-multi.js +++ b/test/parallel/test-domain-multi.js @@ -19,6 +19,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +// Flags: --no-deprecation + 'use strict'; // Tests of multiple domains happening at once. diff --git a/test/parallel/test-domain-promise.js b/test/parallel/test-domain-promise.js index 7b1796d84fea..b96a4cd64a4c 100644 --- a/test/parallel/test-domain-promise.js +++ b/test/parallel/test-domain-promise.js @@ -1,3 +1,5 @@ +// Flags: --no-deprecation + 'use strict'; const common = require('../common'); const assert = require('assert');