Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util.inspect with showHidden does not display exotic object name #36151

Closed
guybedford opened this issue Nov 17, 2020 · 4 comments
Closed

util.inspect with showHidden does not display exotic object name #36151

guybedford opened this issue Nov 17, 2020 · 4 comments
Labels
util Issues and PRs related to the built-in util module.

Comments

@guybedford
Copy link
Contributor

  • Version: 15.2.1
  • Platform: Windows
  • Subsystem: Util

What steps will reproduce the bug?

test.mjs

import util from 'util';
import * as m from './test.mjs';
console.log(util.inspect(m, { showHidden: true }));

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

[Module] { [Symbol(Symbol.toStringTag)]: 'Module' }

What do you see instead?

[] { [Symbol(Symbol.toStringTag)]: 'Module' }

Where the leading [] seems like a display bug.

@BridgeAR
Copy link
Member

It should probably be: [Module] {}. It's a custom inspect function that constructs a special object and it seems like the way it's constructed is not handled as it should be.

@BridgeAR
Copy link
Member

BridgeAR commented Nov 17, 2020

I am quite confused about the value of the Symbol.toStringTag of m. It's actually a descriptor object even though it should be a string. @guybedford do you know where the symbol is assigned?

@guybedford
Copy link
Contributor Author

@BridgeAR it's a module namespace exotic object, so it's a language symbol. The symbol logging seems like it makes sense when using showHidden, the issue is more that the tag name is being lost somehow.

@BridgeAR
Copy link
Member

Ok, I found the issue. The array notation is hard coded, thus it's not working as expected. The output should be [Module: null prototype] { [Symbol(Symbol.toStringTag)]: 'Module' }. This is a fix:

index 4e1ed55c81..b02c4bd3e3 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -977,7 +977,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
       braces[0] = `${getPrefix(constructor, tag, 'WeakMap')}{`;
       formatter = ctx.showHidden ? formatWeakMap : formatWeakCollection;
     } else if (isModuleNamespaceObject(value)) {
-      braces[0] = `[${tag}] {`;
+      braces[0] = `${getPrefix(constructor, tag, 'Module')}{`;
       // Special handle keys for namespace objects.
       formatter = formatNamespaceObject.bind(null, keys);
     } else if (isBoxedPrimitive(value)) {

BridgeAR added a commit to BridgeAR/node that referenced this issue Nov 19, 2020
@PoojaDurgad PoojaDurgad added the util Issues and PRs related to the built-in util module. label Nov 20, 2020
nodejs-github-bot pushed a commit that referenced this issue Dec 12, 2020
Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: #35730

PR-URL: #36178
Fixes: #36151
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this issue Dec 21, 2020
Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: #36151

PR-URL: #36178
Fixes: #35730
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this issue Dec 21, 2020
Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: #35730

PR-URL: #36178
Fixes: #36151
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 27, 2021
Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: nodejs#36151

PR-URL: nodejs#36178
Fixes: nodejs#35730
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 27, 2021
Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: nodejs#35730

PR-URL: nodejs#36178
Fixes: nodejs#36151
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 27, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: nodejs#36151

PR-URL: nodejs#36178
Fixes: nodejs#35730
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 27, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: nodejs#35730

PR-URL: nodejs#36178
Fixes: nodejs#36151
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: nodejs#36151

PR-URL: nodejs#36178
Fixes: nodejs#35730
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: nodejs#35730

PR-URL: nodejs#36178
Fixes: nodejs#36151
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: nodejs#36151

PR-URL: nodejs#36178
Fixes: nodejs#35730
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: nodejs#35730

PR-URL: nodejs#36178
Fixes: nodejs#36151
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: nodejs#36151

PR-URL: nodejs#36178
Fixes: nodejs#35730
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <[email protected]>

Fixes: nodejs#35730

PR-URL: nodejs#36178
Fixes: nodejs#36151
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
BethGriggs pushed a commit that referenced this issue Feb 5, 2021
Signed-off-by: Ruben Bridgewater <[email protected]>

Backport-PR-URL: #37100
PR-URL: #36178
Fixes: #35730
Fixes: #36151
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
BethGriggs pushed a commit that referenced this issue Feb 5, 2021
Signed-off-by: Ruben Bridgewater <[email protected]>

Backport-PR-URL: #37100
PR-URL: #36178
Fixes: #35730
Fixes: #36151
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
BethGriggs pushed a commit that referenced this issue Feb 5, 2021
Signed-off-by: Ruben Bridgewater <[email protected]>

Backport-PR-URL: #37100
PR-URL: #36178
Fixes: #35730
Fixes: #36151
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants