mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
async_hooks: deprecate the AsyncResource.bind asyncResource property
Runtime-deprecates the `asyncResource` property that is attached to the wrapper function returned by `asyncResource.bind()`. This property is not expected to align with the equivalent `asyncContext.wrap()` API in the proposed TC39 standard. PR-URL: https://github.com/nodejs/node/pull/46432 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
1118db718c
commit
9fafb0a090
3 changed files with 35 additions and 9 deletions
|
@ -20,7 +20,10 @@ const {
|
|||
ERR_ASYNC_TYPE,
|
||||
ERR_INVALID_ASYNC_ID
|
||||
} = require('internal/errors').codes;
|
||||
const { kEmptyObject } = require('internal/util');
|
||||
const {
|
||||
deprecate,
|
||||
kEmptyObject,
|
||||
} = require('internal/util');
|
||||
const {
|
||||
validateFunction,
|
||||
validateString,
|
||||
|
@ -237,6 +240,7 @@ class AsyncResource {
|
|||
} else {
|
||||
bound = FunctionPrototypeBind(this.runInAsyncScope, this, fn, thisArg);
|
||||
}
|
||||
let self = this;
|
||||
ObjectDefineProperties(bound, {
|
||||
'length': {
|
||||
__proto__: null,
|
||||
|
@ -249,8 +253,12 @@ class AsyncResource {
|
|||
__proto__: null,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
value: this,
|
||||
writable: true,
|
||||
get: deprecate(function() {
|
||||
return self;
|
||||
}, 'The asyncResource property on bound functions is deprecated', 'DEP0172'),
|
||||
set: deprecate(function(val) {
|
||||
self = val;
|
||||
}, 'The asyncResource property on bound functions is deprecated', 'DEP0172'),
|
||||
}
|
||||
});
|
||||
return bound;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue