| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1118db7 commit 9fafb0a
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -455,6 +455,11 @@ added: | |||
| 455 | 455 | - v14.8.0 | |
| 456 | 456 | - v12.19.0 | |
| 457 | 457 | changes: | |
| 458 | + - version: REPLACEME | ||
| 459 | + pr-url: https://github.com/nodejs/node/pull/46432 | ||
| 460 | + description: The `asyncResource` property added to the bound function | ||
| 461 | + has been deprecated and will be removed in a future | ||
| 462 | + version. | ||
| 458 | 463 | - version: | |
| 459 | 464 | - v17.8.0 | |
| 460 | 465 | - v16.15.0 | |
@@ -473,16 +478,18 @@ changes: | |||
| 473 | 478 | ||
| 474 | 479 | Binds the given function to the current execution context. | |
| 475 | 480 | ||
| 476 | - The returned function will have an `asyncResource` property referencing | ||
| 477 | - the `AsyncResource` to which the function is bound. | ||
| 478 | - | ||
| 479 | 481 | ### `asyncResource.bind(fn[, thisArg])` | |
| 480 | 482 | ||
| 481 | 483 | <!-- YAML | |
| 482 | 484 | added: | |
| 483 | 485 | - v14.8.0 | |
| 484 | 486 | - v12.19.0 | |
| 485 | 487 | changes: | |
| 488 | + - version: REPLACEME | ||
| 489 | + pr-url: https://github.com/nodejs/node/pull/46432 | ||
| 490 | + description: The `asyncResource` property added to the bound function | ||
| 491 | + has been deprecated and will be removed in a future | ||
| 492 | + version. | ||
| 486 | 493 | - version: | |
| 487 | 494 | - v17.8.0 | |
| 488 | 495 | - v16.15.0 | |
@@ -499,9 +506,6 @@ changes: | |||
| 499 | 506 | ||
| 500 | 507 | Binds the given function to execute to this `AsyncResource`'s scope. | |
| 501 | 508 | ||
| 502 | - The returned function will have an `asyncResource` property referencing | ||
| 503 | - the `AsyncResource` to which the function is bound. | ||
| 504 | - | ||
| 505 | 509 | ### `asyncResource.runInAsyncScope(fn[, thisArg, ...args])` | |
| 506 | 510 | ||
| 507 | 511 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3339,6 +3339,20 @@ In a future version of Node.js, [`message.headers`][], | |||
| 3339 | 3339 | [`message.headersDistinct`][], [`message.trailers`][], and | |
| 3340 | 3340 | [`message.trailersDistinct`][] will be read-only. | |
| 3341 | 3341 | ||
| 3342 | + ### DEP0172: The `asyncResource` property of `AsyncResource` bound functions | ||
| 3343 | + | ||
| 3344 | + <!-- YAML | ||
| 3345 | + changes: | ||
| 3346 | + - version: REPLACEME | ||
| 3347 | + pr-url: https://github.com/nodejs/node/pull/46432 | ||
| 3348 | + description: Runtime-deprecation. | ||
| 3349 | + --> | ||
| 3350 | + | ||
| 3351 | + Type: Runtime | ||
| 3352 | + | ||
| 3353 | + In a future version of Node.js, the `asyncResource` property will no longer | ||
| 3354 | + be added when a function is bound to an `AsyncResource`. | ||
| 3355 | + | ||
| 3342 | 3356 | [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 3343 | 3357 | [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 | |
| 3344 | 3358 | [RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,10 @@ const { | |||
| 20 | 20 | ERR_ASYNC_TYPE, | |
| 21 | 21 | ERR_INVALID_ASYNC_ID | |
| 22 | 22 | } = require('internal/errors').codes; | |
| 23 | - const { kEmptyObject } = require('internal/util'); | ||
| 23 | + const { | ||
| 24 | + deprecate, | ||
| 25 | + kEmptyObject, | ||
| 26 | + } = require('internal/util'); | ||
| 24 | 27 | const { | |
| 25 | 28 | validateFunction, | |
| 26 | 29 | validateString, | |
@@ -237,6 +240,7 @@ class AsyncResource { | |||
| 237 | 240 | } else { | |
| 238 | 241 | bound = FunctionPrototypeBind(this.runInAsyncScope, this, fn, thisArg); | |
| 239 | 242 | } | |
| 243 | + let self = this; | ||
| 240 | 244 | ObjectDefineProperties(bound, { | |
| 241 | 245 | 'length': { | |
| 242 | 246 | __proto__: null, | |
@@ -249,8 +253,12 @@ class AsyncResource { | |||
| 249 | 253 | __proto__: null, | |
| 250 | 254 | configurable: true, | |
| 251 | 255 | enumerable: true, | |
| 252 | - value: this, | ||
| 253 | - writable: true, | ||
| 256 | + get: deprecate(function() { | ||
| 257 | + return self; | ||
| 258 | + }, 'The asyncResource property on bound functions is deprecated', 'DEP0172'), | ||
| 259 | + set: deprecate(function(val) { | ||
| 260 | + self = val; | ||
| 261 | + }, 'The asyncResource property on bound functions is deprecated', 'DEP0172'), | ||
| 254 | 262 | } | |
| 255 | 263 | }); | |
| 256 | 264 | return bound; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments