Skip to content

Only apply conn_max_requests to HTTP/1 connections - #4777

Open
alco wants to merge 1 commit into
mainfrom
fix--conn-max-requests-http1-only
Open

Only apply conn_max_requests to HTTP/1 connections#4777
alco wants to merge 1 commit into
mainfrom
fix--conn-max-requests-http1-only

Conversation

@alco

@alco alco commented Aug 26, 2026

Copy link
Copy Markdown
Member

ELECTRIC_TWEAKS_CONN_MAX_REQUESTS was being applied to both HTTP/1 and HTTP/2 Bandit connections, but the option means very different things under each protocol.

Under HTTP/1, reaching max_requests closes the connection at a request boundary, recycling the long-lived handler process and its accumulated heap — the reason the tweak exists. Under HTTP/2, requests already run in short-lived per-stream processes, and once the cumulative stream count reaches max_requests Bandit raises a connection-level error and tears down the whole multiplexed connection with GOAWAY/REFUSED_STREAM. With the default of 50, this routinely cycled HTTP/2 connections, disrupted in-flight streams, and could produce synchronized reconnect bursts.

The limit is now only passed in http_1_options; HTTP/2 connections keep Bandit's default of no request limit.

Fixes #4771

🤖 Generated with Claude Code

https://claude.ai/code/session_012zNLCRpP2XfBci3xmyTEGn

`ELECTRIC_TWEAKS_CONN_MAX_REQUESTS` was passed to both Bandit's
`http_1_options` and `http_2_options`, but the option behaves very
differently under each protocol.

For HTTP/1, requests are served sequentially by a long-lived handler
process and reaching `max_requests` closes the connection at a request
boundary, recycling that process and its accumulated heap. That is the
reason the tweak was introduced.

For HTTP/2, requests already run in short-lived per-stream processes, so
the memory concern doesn't apply. Once the cumulative stream count on a
connection reaches `max_requests`, Bandit raises a connection-level error
and tears down the whole multiplexed connection with GOAWAY/REFUSED_STREAM,
disrupting concurrent streams. With the default of 50 this routinely
cycled HTTP/2 connections and could produce synchronized reconnect bursts.

Leave `http_2_options[:max_requests]` unset so Bandit's default of no
limit applies, and add a regression test for the generated options.

Fixes #4771

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012zNLCRpP2XfBci3xmyTEGn
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.

Do not apply conn_max_requests to HTTP/2 connections

1 participant