From 07968ac456c7b95a38ae1ede91c211bfc6eaab47 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 dddf6501752c52..9a4fed9b200c74 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -217,12 +217,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;