Skip to content

Commit

Permalink
async_hooks: improve property descriptors in als.bind
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Flarna authored and addaleax committed Sep 22, 2020
1 parent 45d2f4d commit 07968ac
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 07968ac

Please sign in to comment.