Skip to content

inspector: avoid mutable push in http2 writev - #67891

Open
rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:inspector-http2-writev-no-push
Open

rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:inspector-http2-writev-no-push

Conversation

@rozzilla

Copy link
Copy Markdown
Contributor

When a client HTTP/2 request body is sent with writev and mixes strings and Buffers, the network inspection collects the chunks with .push() on a private array.

No existing test reached this branch (test-inspector-network-http2.js only sent a single chunk), so this adds a test case that sends a corked request body made of a string and a Buffer and checks Network.getRequestPostData.

Same approach as #67748, #67751 and #67752: private arrays only, no performance claim.

When a client HTTP/2 request body was sent with writev and mixed
strings and Buffers, the network inspection collected the chunks with
.push() on a private array, which looks up Array.prototype.push at
call time. Replacing that method from user code changed the request
body reported to the inspector. Use indexed assignments instead.

No existing test reached this branch, so add a test case that sends a
corked request body made of a string and a Buffer.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/inspector
@nodejs-github-bot nodejs-github-bot added http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels Nov 30, 2026
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #67891   +/-   ##
=======================================
  Coverage   90.58%   90.59%           
=======================================
  Files         802      802           
  Lines      286659   286659           
  Branches    55370    55380   +10     
=======================================
+ Hits       259676   259693   +17     
+ Misses      17083    17060   -23     
- Partials     9900     9906    +6     
Files with missing lines Coverage Δ
lib/internal/inspector/network_http2.js 92.36% <100.00%> (+4.58%) ⬆️

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

http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run.

2 participants