From 3ea94ec84510f5ecd08b75e6e10ef7c5f5df4fe8 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 6fa0aa0abadd68..34fa49724738e9 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;