From 0af9bee4c3c4b53f2cdb398bbf764baaaea7759b Mon Sep 17 00:00:00 2001 From: Gerhard Stoebich <18708370+Flarna@users.noreply.github.com> Date: Tue, 4 Aug 2020 10:15:42 +0200 Subject: [PATCH] async_hooks: improve property descriptors in als.bind The length property should be non enumerable to match behavior of normal functions. The asyncResource property is enumerable and therefore it should be also writable to avoid issues like there: https://github.com/nodejs/node/pull/30932#discussion_r379679982 Both properties should be configurable. Refs: https://github.com/nodejs/node/pull/34574 PR-URL: https://github.com/nodejs/node/pull/34620 Reviewed-By: Andrey Pechkurov Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- lib/async_hooks.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/async_hooks.js b/lib/async_hooks.js index ccf7b5797ab2be..02362973ae1de6 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -220,12 +220,16 @@ class AsyncResource { const ret = this.runInAsyncScope.bind(this, fn); ObjectDefineProperties(ret, { 'length': { - enumerable: true, + configurable: true, + enumerable: false, value: fn.length, + writable: false, }, 'asyncResource': { + configurable: true, enumerable: true, value: this, + writable: true, } }); return ret;