Skip to content

Commit 0af9bee

Browse files
Flarnaaddaleax
authored andcommitted
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: #30932 (comment) Both properties should be configurable. Refs: #34574 PR-URL: #34620 Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 16aa927 commit 0af9bee

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/async_hooks.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,16 @@ class AsyncResource {
220220
const ret = this.runInAsyncScope.bind(this, fn);
221221
ObjectDefineProperties(ret, {
222222
'length': {
223-
enumerable: true,
223+
configurable: true,
224+
enumerable: false,
224225
value: fn.length,
226+
writable: false,
225227
},
226228
'asyncResource': {
229+
configurable: true,
227230
enumerable: true,
228231
value: this,
232+
writable: true,
229233
}
230234
});
231235
return ret;

0 commit comments

Comments
 (0)