From 308b6bc6de155572af4d9eb110226837f64fb652 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 9 Jun 2025 08:20:30 -0700 Subject: [PATCH] async_hooks: move `asyncResource` property on bound function to EOL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/58618 Reviewed-By: Michaƫl Zasso Reviewed-By: Chengzhong Wu Reviewed-By: Matteo Collina --- doc/api/deprecations.md | 9 ++++++--- lib/async_hooks.js | 13 ------------- test/parallel/test-asyncresource-bind.js | 1 - 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index e8c4bc2a371..85922499d42 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3583,15 +3583,18 @@ In a future version of Node.js, [`message.headers`][], -Type: Runtime +Type: End-of-Life -In a future version of Node.js, the `asyncResource` property will no longer -be added when a function is bound to an `AsyncResource`. +Older versions of Node.js would add the `asyncResource` when a function is +bound to an `AsyncResource`. It no longer does. ### DEP0173: the `assert.CallTracker` class diff --git a/lib/async_hooks.js b/lib/async_hooks.js index 7dc7bfab328..dcb046e13e3 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -20,7 +20,6 @@ const { ERR_INVALID_ASYNC_ID, } = require('internal/errors').codes; const { - deprecate, kEmptyObject, } = require('internal/util'); const { @@ -247,7 +246,6 @@ class AsyncResource { } else { bound = FunctionPrototypeBind(this.runInAsyncScope, this, fn, thisArg); } - let self = this; ObjectDefineProperties(bound, { 'length': { __proto__: null, @@ -256,17 +254,6 @@ class AsyncResource { value: fn.length, writable: false, }, - 'asyncResource': { - __proto__: null, - configurable: true, - enumerable: 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; } diff --git a/test/parallel/test-asyncresource-bind.js b/test/parallel/test-asyncresource-bind.js index 29de9bbb0f1..0d1f5fb62ab 100644 --- a/test/parallel/test-asyncresource-bind.js +++ b/test/parallel/test-asyncresource-bind.js @@ -25,7 +25,6 @@ const fn2 = asyncResource.bind((a, b) => { return executionAsyncId(); }); -assert.strictEqual(fn2.asyncResource, asyncResource); assert.strictEqual(fn2.length, 2); setImmediate(() => {