| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f088ce2 commit b1bde69
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -116,35 +116,24 @@ Each instance of `AsyncLocalStorage` maintains an independent storage context. | |||
| 116 | 116 | Multiple instances can safely exist simultaneously without risk of interfering | |
| 117 | 117 | with each other's data. | |
| 118 | 118 | ||
| 119 | - ### `new AsyncLocalStorage([options])` | ||
| 119 | + ### `new AsyncLocalStorage()` | ||
| 120 | 120 | ||
| 121 | 121 | <!-- YAML | |
| 122 | 122 | added: | |
| 123 | 123 | - v13.10.0 | |
| 124 | 124 | - v12.17.0 | |
| 125 | 125 | changes: | |
| 126 | + - version: REPLACEME | ||
| 127 | + pr-url: https://github.com/nodejs/node/pull/46386 | ||
| 128 | + description: Removed experimental onPropagate option. | ||
| 126 | 129 | - version: v18.13.0 | |
| 127 | 130 | pr-url: https://github.com/nodejs/node/pull/45386 | |
| 128 | 131 | description: Add option onPropagate. | |
| 129 | 132 | --> | |
| 130 | 133 | ||
| 131 | - > Stability: 1 - `options.onPropagate` is experimental. | ||
| 132 | - | ||
| 133 | - * `options` {Object} | ||
| 134 | - * `onPropagate` {Function} Optional callback invoked before a store is | ||
| 135 | - propagated to a new async resource. Returning `true` allows propagation, | ||
| 136 | - returning `false` avoids it. Default is to propagate always. | ||
| 137 | - | ||
| 138 | 134 | Creates a new instance of `AsyncLocalStorage`. Store is only provided within a | |
| 139 | 135 | `run()` call or after an `enterWith()` call. | |
| 140 | 136 | ||
| 141 | - The `onPropagate` is called during creation of an async resource. Throwing at | ||
| 142 | - this time will print the stack trace and exit. See | ||
| 143 | - [`async_hooks` Error handling][] for details. | ||
| 144 | - | ||
| 145 | - Creating an async resource within the `onPropagate` callback will result in | ||
| 146 | - a recursive call to `onPropagate`. | ||
| 147 | - | ||
| 148 | 137 | ### `asyncLocalStorage.disable()` | |
| 149 | 138 | ||
| 150 | 139 | <!-- YAML | |
@@ -830,5 +819,4 @@ const server = createServer((req, res) => { | |||
| 830 | 819 | [`EventEmitter`]: events.md#class-eventemitter | |
| 831 | 820 | [`Stream`]: stream.md#stream | |
| 832 | 821 | [`Worker`]: worker_threads.md#class-worker | |
| 833 | - [`async_hooks` Error handling]: async_hooks.md#error-handling | ||
| 834 | 822 | [`util.promisify()`]: util.md#utilpromisifyoriginal | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,6 @@ const { | |||
| 23 | 23 | const { kEmptyObject } = require('internal/util'); | |
| 24 | 24 | const { | |
| 25 | 25 | validateFunction, | |
| 26 | - validateObject, | ||
| 27 | 26 | validateString, | |
| 28 | 27 | } = require('internal/validators'); | |
| 29 | 28 | const internal_async_hooks = require('internal/async_hooks'); | |
@@ -275,17 +274,9 @@ const storageHook = createHook({ | |||
| 275 | 274 | }); | |
| 276 | 275 | ||
| 277 | 276 | class AsyncLocalStorage { | |
| 278 | - constructor(options = kEmptyObject) { | ||
| 279 | - validateObject(options, 'options'); | ||
| 280 | - | ||
| 281 | - const { onPropagate = null } = options; | ||
| 282 | - if (onPropagate !== null) { | ||
| 283 | - validateFunction(onPropagate, 'options.onPropagate'); | ||
| 284 | - } | ||
| 285 | - | ||
| 277 | + constructor() { | ||
| 286 | 278 | this.kResourceStore = Symbol('kResourceStore'); | |
| 287 | 279 | this.enabled = false; | |
| 288 | - this._onPropagate = onPropagate; | ||
| 289 | 280 | } | |
| 290 | 281 | ||
| 291 | 282 | disable() { | |
@@ -312,9 +303,7 @@ class AsyncLocalStorage { | |||
| 312 | 303 | _propagate(resource, triggerResource, type) { | |
| 313 | 304 | const store = triggerResource[this.kResourceStore]; | |
| 314 | 305 | if (this.enabled) { | |
| 315 | - if (this._onPropagate === null || this._onPropagate(type, store)) { | ||
| 316 | - resource[this.kResourceStore] = store; | ||
| 317 | - } | ||
| 306 | + resource[this.kResourceStore] = store; | ||
| 318 | 307 | } | |
| 319 | 308 | } | |
| 320 | 309 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments