GeezerVison is showing github.com — domain: port to AsyncLocalStorage · nodejs/node@2c4356c
File tree
Expand file treeCollapse file tree
Open diff view settings
make-callback-domain-warning
node-api/test_make_callback_recurse
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/deprecations.md +8-4Lines changed: 8 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2297,16 +2297,20 @@ Type: End-of-Life |
2297 | 2297 |
|
2298 | 2298 | <!-- YAML |
2299 | 2299 | changes: |
| 2300 | + - version: REPLACEME |
| 2301 | + pr-url: https://github.com/nodejs/node/pull/61095 |
| 2302 | + description: End-of-Life. |
2300 | 2303 | - version: v10.0.0 |
2301 | 2304 | pr-url: https://github.com/nodejs/node/pull/17417 |
2302 | 2305 | description: Runtime deprecation. |
2303 | 2306 | --> |
2304 | 2307 |
|
2305 | | -Type: Runtime |
| 2308 | +Type: End-of-Life |
2306 | 2309 |
|
2307 | | -Users of `MakeCallback` that add the `domain` property to carry context, |
2308 | | -should start using the `async_context` variant of `MakeCallback` or |
2309 | | -`CallbackScope`, or the high-level `AsyncResource` class. |
| 2310 | +The `domain` property on async resources and `MakeCallback` has been removed. |
| 2311 | +The domain module now uses `AsyncLocalStorage` for context propagation instead |
| 2312 | +of `async_hooks`. Accessing the `domain` property on `AsyncResource` will throw |
| 2313 | +an error. Use `AsyncLocalStorage` instead for context propagation. |
2310 | 2314 |
|
2311 | 2315 | ### DEP0098: AsyncHooks embedder `AsyncResource.emitBefore` and `AsyncResource.emitAfter` APIs |
2312 | 2316 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: doc/api/errors.md +8Lines changed: 8 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -714,6 +714,14 @@ An attempt was made to register something that is not a function as an |
714 | 714 | An operation related to module loading is customized by an asynchronous loader |
715 | 715 | hook that never settled the promise before the loader thread exits. |
716 | 716 |
|
| 717 | +<a id="ERR_ASYNC_RESOURCE_DOMAIN_REMOVED"></a> |
| 718 | + |
| 719 | +### `ERR_ASYNC_RESOURCE_DOMAIN_REMOVED` |
| 720 | + |
| 721 | +The `domain` property on `AsyncResource` has been removed. The domain module |
| 722 | +now uses `AsyncLocalStorage` for context propagation instead of `async_hooks`. |
| 723 | +Use `AsyncLocalStorage` instead for context propagation. |
| 724 | + |
717 | 725 | <a id="ERR_ASYNC_TYPE"></a> |
718 | 726 |
|
719 | 727 | ### `ERR_ASYNC_TYPE` |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/async_hooks.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -16,6 +16,7 @@ const { |
16 | 16 |
|
17 | 17 | const { |
18 | 18 | ERR_ASYNC_CALLBACK, |
| 19 | + ERR_ASYNC_RESOURCE_DOMAIN_REMOVED, |
19 | 20 | ERR_ASYNC_TYPE, |
20 | 21 | ERR_INVALID_ASYNC_ID, |
21 | 22 | ERR_INVALID_ARG_TYPE, |
@@ -275,6 +276,10 @@ class AsyncResource { |
275 | 276 | type ||= fn.name; |
276 | 277 | return (new AsyncResource(type || 'bound-anonymous-fn')).bind(fn, thisArg); |
277 | 278 | } |
| 279 | + |
| 280 | + get domain() { |
| 281 | + throw new ERR_ASYNC_RESOURCE_DOMAIN_REMOVED(); |
| 282 | + } |
278 | 283 | } |
279 | 284 |
|
280 | 285 | // Placing all exports down here because the exported classes won't export |
|