Skip to content

quic: fix eternal handle leak for HTTP/3 known header names - #67758

Open
pimterry wants to merge 1 commit into
nodejs:mainfrom
pimterry:quic-handle-leak
Open

pimterry wants to merge 1 commit into
nodejs:mainfrom
pimterry:quic-handle-leak

Conversation

@pimterry

Copy link
Copy Markdown
Member

A single character fix!

NgHeader::GetName attempts to cache JS String objects for known common header names. Unfortunately, it didn't. Instead, it effectively created a new permanent cache value for every header, for every request, and threw away the key.

This happens because it copies the v8::Eternal from the cache map, instead of referencing it, and so the subsequent eternal.Set call doesn't actually end up updating the value in the cache - it just updates the local copy. This does store the JS string permanently, but it puts the key into the local copy of the eternal that's dropped at the end of the function. Because it's not cached, we do this every time, not just once.

In practice, this leaks an eternal handle for every known header, for every HTTP/3 request, roughly 8 bytes for header ever received by the process, which can never be collected.

Referencing the eternal from the map instead of copying it fixes this. This matches equivalent code elsewhere, which does have the & already:

v8::Eternal<v8::String>& eternal = static_str_map[header_name];

Signed-off-by: Tim Perry <pimterry@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Nov 24, 2026
@pimterry

Copy link
Copy Markdown
Member Author

@nodejs/quic

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.54%. Comparing base (c01b66b) to head (33f1549).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/node_http_common-inl.h 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67758      +/-   ##
==========================================
- Coverage   90.54%   90.54%   -0.01%     
==========================================
  Files         803      803              
  Lines      285110   285127      +17     
  Branches    55032    55028       -4     
==========================================
+ Hits       258143   258157      +14     
- Misses      17103    17109       +6     
+ Partials     9864     9861       -3     
Files with missing lines Coverage Δ
src/node_http_common-inl.h 67.74% <0.00%> (ø)

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

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants