Skip to content

perf(http2): avoid cloning headers when removing status#5127

Merged
metcoder95 merged 1 commit into
nodejs:mainfrom
trivikr:remove-status-header
May 1, 2026
Merged

perf(http2): avoid cloning headers when removing status#5127
metcoder95 merged 1 commit into
nodejs:mainfrom
trivikr:remove-status-header

Conversation

@trivikr

@trivikr trivikr commented Apr 27, 2026

Copy link
Copy Markdown
Member

This relates to...

N/A

Rationale

Avoid cloning HTTP/2 response headers just to remove the :status pseudo-header before passing headers to request callbacks.

Changes

The response handling now removes :status in place instead of using rest destructuring, avoiding an extra headers object allocation for every H2 response and upgrade response.

Features

N/A

Bug Fixes

N/A

Breaking Changes and Deprecations

N/A

Status

Assisted-by: openai:gpt-5.5

Assisted-by: openai:gpt-5.5
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.14%. Comparing base (9a6e313) to head (354741f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5127   +/-   ##
=======================================
  Coverage   93.14%   93.14%           
=======================================
  Files         110      110           
  Lines       36117    36119    +2     
=======================================
+ Hits        33642    33644    +2     
  Misses       2475     2475           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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


const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers
const statusCode = headers[HTTP2_HEADER_STATUS]
delete headers[HTTP2_HEADER_STATUS]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sits on the critical path, do we have potential perf regression?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This is perf improvement since memory for object realHeaders is not allocated.

@trivikr trivikr requested a review from metcoder95 May 1, 2026 00:25
@metcoder95 metcoder95 merged commit 72a7591 into nodejs:main May 1, 2026
35 checks passed
@github-actions github-actions Bot mentioned this pull request May 1, 2026
@trivikr trivikr deleted the remove-status-header branch May 6, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants