Skip to content

Do not reset the HTTP/2 idle timeout when no request is in progress - #1771

Draft
essen wants to merge 1 commit into
masterfrom
h2-idle-no-request
Draft

essen wants to merge 1 commit into
masterfrom
h2-idle-no-request

Conversation

@essen

@essen essen commented Dec 3, 2026

Copy link
Copy Markdown
Member

Frames received while no stream exists no longer restart idle_timeout. A client request restarts it when its stream is created. Data received while a stream exists still restarts it. Server push does not.

I'm not sure this will be ready in time for 2.22 so it might ship in 2.23 instead.

Frames received while no stream exists no longer restart idle_timeout.
A client request restarts it when its stream is created. Data received
while a stream exists still restarts it. Server push does not.
@essen
essen requested a review from grok-99s December 3, 2026 15:36
idle_timeout (60000)::

Time in ms with no data received before Cowboy closes the connection.
Time in ms before Cowboy closes the connection.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking: "before Cowboy closes the connection" no longer says what is being timed. Something like "with no activity" plus the rule below would read better. The last two sentences of the paragraph also say the same thing twice.

The timer is reset when a request stream is created, and when
data is received while a stream exists. Frames received while
no stream exists do not reset it. A header block that does not
create a stream does not reset it either.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking: a request that is rejected before a stream is created is not counted, and that includes requests answered by early_error (CONNECT/TRACE, 501). Reproduced: with idle_timeout 1000, a client sending one TRACE every 300ms and getting a 501 each time is closed after about 1.2s. On master it stays open. Valid requests (GET every 300ms) stay open. Probably fine, but a request that gets a response is arguably in progress.

Comment thread test/http2_SUITE.erl
%% The connection goes away soon after we stop sending data.
timer:sleep(1000),
{ok, << _:24, 7:8, _:72, 0:32 >>} = gen_tcp:recv(Socket, 17, 1000),
%% Longer than the idle timeout. A PING used to reset it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking: "A PING used to reset it." is history, not intent. Drop that sentence.

Comment thread test/http2_SUITE.erl
cowboy:stop_listener(?FUNCTION_NAME)
end.

do_start_idle_listener(Name, Config, IdleTimeout) ->

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking (erlanger): six new tests and eight do_* helpers (about 25s of added runtime). Bodies should be inline, and ping_without_request, ping_after_request and continuation_without_request overlap. The suite already has do_handshake. Checked: the first three fail on master and request_resets fails if the headers_frame reset is removed. push_does_not_reset fails if that reset is made unconditional.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants