Skip to content

doc: fix incorrect default for maxHeadersCount - #65505

Open
suraj-shrivastav wants to merge 1 commit into
nodejs:mainfrom
suraj-shrivastav:doc-fix-maxheaderscount
Open

doc: fix incorrect default for maxHeadersCount#65505
suraj-shrivastav wants to merge 1 commit into
nodejs:mainfrom
suraj-shrivastav:doc-fix-maxheaderscount

Conversation

@suraj-shrivastav

Copy link
Copy Markdown

request.maxHeadersCount and server.maxHeadersCount are documented with a
default of 2000. The underlying parser limit, MAX_HEADER_PAIRS in
lib/_http_common.js, counts name/value pairs (2 slots per header), so the
effective maximum number of headers is 1000, not 2000.

Also note that in practice server.maxHeadersCount and
request.maxHeadersCount default to null (see lib/_http_server.js and
lib/_http_client.js); when null, the wiring that sets
parser.maxHeaderPairs from the option never runs, and the parser falls
back to its own hardcoded 2000-pair (1000-header) constant. This PR keeps
the documented default as a plain number for consistency with the
existing docs style and focuses on correcting the number itself.

Verified against a live server: sending 1000 custom headers returns all
1000 in req.headers, while sending 1001 still returns only 1000, with the
1001st silently dropped. This confirms the effective cap is 1000 headers.

Fixes: #65470


Disclosure: root cause and fix were researched and drafted with the
assistance of a closed-source coding agent, then verified by hand against
the live source and a running server before submitting.

request.maxHeadersCount and server.maxHeadersCount were documented
with a default of 2000. The underlying parser limit,
MAX_HEADER_PAIRS in lib/_http_common.js, is a count of name/value
pairs (2 slots per header), so the effective maximum number of
headers is 1000, not 2000.

Verified against a running server: sending 1000 headers returns all
of them, while sending 1001 headers still returns only 1000, with
the extra header silently dropped.

Fixes: nodejs#65470
Signed-off-by: suraj-shrivastav <suraj.shrivastavvv@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem. labels Aug 23, 2026
@lpinca

lpinca commented Aug 23, 2026

Copy link
Copy Markdown
Member

Duplicate of #65472.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stated server.maxHeadersCount default is off by a factor of two

3 participants