Skip to content

util: use internal hexSlice directly in util.inspect() - #66974

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
LiviaMedeiros:util-inspect-arraybuffer-hexslice
Oct 30, 2026
Merged

nodejs-github-bot merged 2 commits into
nodejs:mainfrom
LiviaMedeiros:util-inspect-arraybuffer-hexslice

Conversation

@LiviaMedeiros

Copy link
Copy Markdown
Member

hexSlice, used by util.inspect to format ArrayBuffers, is used in a quite roundabout way: it's wrapped in a function to be set on Buffer.prototype, gets lazily retrieved from the userland-facing prototype, and then uncurried. As a side effect, it's prone to prototype pollution at any moment before a buffer gets inspected.
It would be more straightforward to export it from internal/buffer and use directly.

I'm not sure why it was added with lazy-loading (cc @BridgeAR). If there is a strong reason for that, we can lazy-load it from internal/buffer in the same way.

Signed-off-by: LiviaMedeiros <livia@cirno.name>
Signed-off-by: LiviaMedeiros <livia@cirno.name>
@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Oct 24, 2026
@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.58%. Comparing base (b12bad4) to head (7049c38).
⚠️ Report is 96 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66974      +/-   ##
==========================================
- Coverage   92.93%   90.58%   -2.35%     
==========================================
  Files         428      797     +369     
  Lines      195236   278299   +83063     
  Branches    30183    53519   +23336     
==========================================
+ Hits       181442   252109   +70667     
- Misses      13467    16562    +3095     
- Partials      327     9628    +9301     
Files with missing lines Coverage Δ
lib/internal/buffer.js 98.96% <100.00%> (+0.69%) ⬆️
lib/internal/util/inspect.js 97.04% <100.00%> (+20.97%) ⬆️

... and 499 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.

@LiviaMedeiros LiviaMedeiros added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 28, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 28, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@LiviaMedeiros LiviaMedeiros added author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Oct 30, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 97aed16 into nodejs:main Oct 30, 2026
100 of 101 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 97aed16

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. buffer Issues and PRs related to the buffer subsystem. commit-queue-squash PRs the Commit Queue should land as one squashed commit. 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.

4 participants