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 codebytere committed Aug 11, 2020
1 parent ef4fb68 commit 0730c76
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/async_hooks.js
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 0730c76

Please sign in to comment.