Skip to content

fix: avoid prototype collisions in parseHeaders#4923

Merged
mcollina merged 2 commits intomainfrom
fix-header-prototype-collision
Mar 23, 2026
Merged

fix: avoid prototype collisions in parseHeaders#4923
mcollina merged 2 commits intomainfrom
fix-header-prototype-collision

Conversation

@mcollina
Copy link
Member

Fix parseHeaders() for response headers and trailers that shadow Object.prototype.

Adds regression tests.

@mcollina mcollina requested review from Uzlopak and tsctx March 23, 2026 09:37
@ronag
Copy link
Member

ronag commented Mar 23, 2026

Perf impact?

@codecov-commenter
Copy link

codecov-commenter commented Mar 23, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4923      +/-   ##
==========================================
+ Coverage   92.93%   92.94%   +0.01%     
==========================================
  Files         112      112              
  Lines       35711    35709       -2     
==========================================
+ Hits        33188    33191       +3     
+ Misses       2523     2518       -5     

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

@tsctx
Copy link
Member

tsctx commented Mar 23, 2026

Perf impact?

  • main
> node ./benchmarks/core/parse-headers.mjs
clk: ~3.21 GHz
cpu: AMD Ryzen 7 8845HS w/ Radeon 780M Graphics
runtime: node 25.8.1 (x64-win32)

benchmark                   avg (min … max) p75 / p99    (min … top 1%)
------------------------------------------- -------------------------------
• parseHeaders
------------------------------------------- -------------------------------
parseHeaders                   6.65 µs/iter   6.72 µs     █  ██
                        (6.20 µs … 7.81 µs)   7.34 µs   ███  ██
                    (609.53  b …   2.59 kb)   2.37 kb █▁████▁█████▁▁▁█▁▁▁▁█

parseHeaders (irregular)       6.80 µs/iter   7.02 µs ██
                        (6.30 µs … 9.27 µs)   7.92 µs ██▂▂
                    (  2.59 kb …   2.60 kb)   2.59 kb ████▆▁▁▁▁▆▁▁▁▆▆▁▆▁▁▁▆
  • this PR
> node ./benchmarks/core/parse-headers.mjs
clk: ~3.23 GHz
cpu: AMD Ryzen 7 8845HS w/ Radeon 780M Graphics
runtime: node 25.8.1 (x64-win32)

benchmark                   avg (min … max) p75 / p99    (min … top 1%)
------------------------------------------- -------------------------------
• parseHeaders
------------------------------------------- -------------------------------
parseHeaders                  16.86 µs/iter  15.00 µs █
                     (14.20 µs … 303.20 µs)  36.40 µs █
                    (648.00  b … 260.46 kb)   5.33 kb █▆▂▁▁▁▂▁▁▁▁▁▂▂▁▁▁▁▁▁▁

parseHeaders (irregular)      17.05 µs/iter  16.79 µs   █     █
                      (15.00 µs … 27.50 µs)  18.01 µs ▅▅█ ▅   █▅  ▅ ▅     ▅
                    (  1.06 kb …   5.06 kb)   4.26 kb ███▁█▁▁▁██▁▁█▁█▁▁▁▁▁█

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina mcollina force-pushed the fix-header-prototype-collision branch from 1f12065 to 65fcb98 Compare March 23, 2026 10:28
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
Copy link
Member Author

Fixing it.

@mcollina
Copy link
Member Author

ptal @tsctx

@mcollina
Copy link
Member Author

Should have no regressions now.

Copy link
Member

@tsctx tsctx left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit b64e7e4 into main Mar 23, 2026
36 of 37 checks passed
@mcollina mcollina deleted the fix-header-prototype-collision branch March 23, 2026 11:04
@github-actions github-actions bot mentioned this pull request Mar 24, 2026
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.

4 participants