Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2272,16 +2272,20 @@ Type: End-of-Life

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/61095
description: End-of-Life.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/17417
description: Runtime deprecation.
-->

Type: Runtime
Type: End-of-Life

Users of `MakeCallback` that add the `domain` property to carry context,
should start using the `async_context` variant of `MakeCallback` or
`CallbackScope`, or the high-level `AsyncResource` class.
The `domain` property on async resources and `MakeCallback` has been removed.
The domain module now uses `AsyncLocalStorage` for context propagation instead
of `async_hooks`. Accessing the `domain` property on `AsyncResource` will throw
an error. Use `AsyncLocalStorage` instead for context propagation.

### DEP0098: AsyncHooks embedder `AsyncResource.emitBefore` and `AsyncResource.emitAfter` APIs

Expand Down
8 changes: 8 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,14 @@ An attempt was made to register something that is not a function as an
An operation related to module loading is customized by an asynchronous loader
hook that never settled the promise before the loader thread exits.

<a id="ERR_ASYNC_RESOURCE_DOMAIN_REMOVED"></a>

### `ERR_ASYNC_RESOURCE_DOMAIN_REMOVED`

The `domain` property on `AsyncResource` has been removed. The domain module
now uses `AsyncLocalStorage` for context propagation instead of `async_hooks`.
Use `AsyncLocalStorage` instead for context propagation.

<a id="ERR_ASYNC_TYPE"></a>

### `ERR_ASYNC_TYPE`
Expand Down
5 changes: 5 additions & 0 deletions lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {

const {
ERR_ASYNC_CALLBACK,
ERR_ASYNC_RESOURCE_DOMAIN_REMOVED,
ERR_ASYNC_TYPE,
ERR_INVALID_ASYNC_ID,
} = require('internal/errors').codes;
Expand Down Expand Up @@ -262,6 +263,10 @@ class AsyncResource {
type ||= fn.name;
return (new AsyncResource(type || 'bound-anonymous-fn')).bind(fn, thisArg);
}

get domain() {
throw new ERR_ASYNC_RESOURCE_DOMAIN_REMOVED();
}
}

// Placing all exports down here because the exported classes won't export
Expand Down
Loading
Loading