Skip to content

http: avoid mutable push on private arrays - #67885

Open
rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:http-private-arrays-no-push
Open

rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:http-private-arrays-no-push

Conversation

@rozzilla

@rozzilla rozzilla commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

The server's per-connection incoming/outgoing queues, the uncork() and end() callback lists in OutgoingMessage, and the socket sets in Agent.prototype.removeSocket() used .push() on private arrays. If user code replaced Array.prototype.push, these paths went through it. This uses indexed assignments instead.

lib/internal/http/*.js must not use prototype primordials, the same as lib/zlib.js, so this follows #67748. Private arrays only, no performance claim.

The server's per-connection request and response queues, the uncork()
and end() callback lists in OutgoingMessage, and the socket sets in
Agent.prototype.removeSocket() used .push() on private arrays, which
looks up Array.prototype.push at call time. These files do not use
prototype primordials, so replacing that method from user code changed
how they ran. Use indexed assignments instead.

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

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http Issues and PRs related to the http 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 (1611823) to head (9baa7ea).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #67885   +/-   ##
=======================================
  Coverage   90.58%   90.59%           
=======================================
  Files         802      802           
  Lines      286656   286656           
  Branches    55369    55372    +3     
=======================================
+ Hits       259668   259691   +23     
+ Misses      17089    17076   -13     
+ Partials     9899     9889   -10     
Files with missing lines Coverage Δ
lib/internal/http/agent.js 96.87% <100.00%> (ø)
lib/internal/http/outgoing.js 98.03% <100.00%> (ø)
lib/internal/http/server.js 96.45% <100.00%> (ø)

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants