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

PR-URL: nodejs#34620
Reviewed-By: Andrey Pechkurov <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Flarna committed Aug 4, 2020
1 parent 0bb70b0 commit 3ea94ec
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 3ea94ec

Please sign in to comment.