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:
nodejs#30932 (comment)

Both properties should be configurable.

Refs: nodejs#34574
  • Loading branch information
Flarna committed Aug 4, 2020
1 parent 74df749 commit ccc0467
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 @@ -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;
Expand Down

0 comments on commit ccc0467

Please sign in to comment.