Repository navigation
fix: cancel the keepalive timer after an HTTP/1.1 TLS upgrade - #1042
Conversation
A freshly dialed pooled conn arms the keepalive timer on entering
connected. upgrade_to_ssl blocks the conn in ssl:connect/3, and the
HTTP/1.1 branch kept the timer running, so a handshake slower than
keepalive_timeout closed the conn right after the upgrade returned and
the caller got {error, closed}. Cancel it as the HTTP/2 branch does.
Fixes benoitc#938
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks, the fix is right. CI is red because of the new test, not DNS. It sends Optional: a test through |
|
Thanks for the review and for spotting the cause. You're right: the stray |
The message leaked into the test process mailbox and broke a later integration test that does a bare receive.
What
In the HTTP/1.1 branch of
upgrade_to_ssl, cancel the keepalivestate_timeout(as the HTTP/2 branch already does throughinit_h2_after_upgrade).Why
A freshly dialed pooled conn arms
idle_timeoutwhen it entersconnected, andssl:connect/3blocks the conn process. If the handshake takes longer thankeepalive_timeout(capped at 2000 ms), the timer fires as soon as the upgrade returns. The conn goes toclosedbefore the request is written, and the caller gets an error. #934 only covers reused conns viais_ready. The timer is re-armed when the conn re-entersconnectedafter the request.Fixes #938
How to test
rebar3 eunit --module=hackney_conn_upgrade_idle_tests. The test delays the server's TLS handshake pastidle_timeout. It fails before the change (conn isclosed) and passes after. The upgrade, pool-checkout-idle and TLS-resumption suites also pass. In the fullrebar3 eunitrun, the only failure ishackney_happy_tests"connect to non-existent domain fails", which needs DNS and the sandbox has none.This change was prepared with AI assistance (Claude Code) and reviewed against the repo's tests.