Skip to content

util: canonicalize namespaced tags in inspect()#63257

Open
Renegade334 wants to merge 1 commit into
nodejs:mainfrom
Renegade334:inspect-namespaced-tags
Open

util: canonicalize namespaced tags in inspect()#63257
Renegade334 wants to merge 1 commit into
nodejs:mainfrom
Renegade334:inspect-namespaced-tags

Conversation

@Renegade334
Copy link
Copy Markdown
Member

@Renegade334 Renegade334 commented May 11, 2026

Precursor to adding support for Temporal objects in #63154.

Namespaced toString tags are becoming more common in ES builtins. inspect() currently has no logic for dealing with these, leading to rather ugly output:

> new WebAssembly.Memory({ initial: 1 })
Memory [WebAssembly.Memory] {}

This PR adds logic to handle namespaced tags. If the basename of the namespaced tag matches the constructor name, then it will be treated as the canonical name for that object. Derived classes retain the same behaviour as exists currently.

> class Class {
>   get [Symbol.toStringTag]() { return 'Namespaced.Class' }
> }
> new Class()
Namespaced.Class {}

> class DerivedClass extends Class {}
> new DerivedClass()
DerivedClass [Namespaced.Class] {}

Note that this replaces, and effectively reverts, some previous logic that existed here from #59687. That PR made partial string tag matches be considered hits, so FooBarBaz would match Foo and suppress the additional tag output. This logic doesn't really fit with namespaced tags, and I think the easiest approach is just to replace it entirely. (cc @BridgeAR, @miguelmarcondesf)

Signed-off-by: Renegade334 <contact.9a5d6388@renegade334.me.uk>
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels May 11, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.04%. Comparing base (a2aeb72) to head (b7bebca).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #63257   +/-   ##
=======================================
  Coverage   90.03%   90.04%           
=======================================
  Files         713      713           
  Lines      224950   224945    -5     
  Branches    42531    42530    -1     
=======================================
+ Hits       202527   202541   +14     
+ Misses      14218    14187   -31     
- Partials     8205     8217   +12     
Files with missing lines Coverage Δ
lib/internal/util/inspect.js 99.54% <100.00%> (+0.03%) ⬆️

... and 28 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants