Repository navigation
util.inspect fails to log getters which access this #36045
Copy link
Copy link
Closed
Labels
utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.
Description
Activity
@nodejs/util
- addedutilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.
on Nov 9, 2020 diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index e6787760fe..9343b0772f 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -628,7 +628,7 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, output) { continue; } const value = formatProperty( - ctx, obj, recurseTimes, key, kObjectType, desc); + ctx, obj, recurseTimes, key, kObjectType, desc, main); if (ctx.colors) { // Faint! output.push(`\u001b[2m${value}\u001b[22m`); @@ -1678,7 +1678,7 @@ function formatPromise(ctx, value, recurseTimes) { return output; } -function formatProperty(ctx, value, recurseTimes, key, type, desc) { +function formatProperty(ctx, value, recurseTimes, key, type, desc, original = value) { let name, str; let extra = ' '; desc = desc || ObjectGetOwnPropertyDescriptor(value, key) || @@ -1699,7 +1699,7 @@ function formatProperty(ctx, value, recurseTimes, key, type, desc) { (ctx.getters === 'get' && desc.set === undefined) || (ctx.getters === 'set' && desc.set !== undefined))) { try { - const tmp = value[key]; + const tmp = desc.get.call(original); ctx.indentationLvl += 2; if (tmp === null) { str = `${s(`[${label}:`, sp)} ${s('null', 'null')}${s(']', sp)}`;
This would be a functional fix. I did not yet check if this causes a performance regression due to mismatching the arguments count frequently.
- added a commit that references this issue
on Nov 12, 2020 - added a commit that references this issue
on Nov 22, 2020
Metadata
Metadata
Assignees
Labels
utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.
Linux solus 5.6.19-159.current #1 SMP PREEMPT Fri Oct 16 17:49:06 UTC 2020 x86_64 GNU/LinuxWhat steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
What do you see instead?
Additional information
May be related with #35956