From 4d23d3066563aa84710cb84f9f2d0bf9d33d5af0 Mon Sep 17 00:00:00 2001 From: Chris Keathley Date: Mon, 4 May 2026 10:39:11 -0400 Subject: [PATCH] If receive times out, return the error instead of closing the connection --- lib/mint/http1.ex | 1 + lib/mint/http2.ex | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib/mint/http1.ex b/lib/mint/http1.ex index 941e12d0..fba50973 100644 --- a/lib/mint/http1.ex +++ b/lib/mint/http1.ex @@ -551,6 +551,7 @@ defmodule Mint.HTTP1 do case conn.transport.recv(conn.socket, byte_count, timeout) do {:ok, data} -> handle_data(conn, data) {:error, %Mint.TransportError{reason: :closed}} -> handle_close(conn) + {:error, %Mint.TransportError{reason: :timeout} = error} -> {:error, conn, error, []} {:error, error} -> handle_transport_error(conn, error) end end diff --git a/lib/mint/http2.ex b/lib/mint/http2.ex index d1b562d0..e6745900 100644 --- a/lib/mint/http2.ex +++ b/lib/mint/http2.ex @@ -874,6 +874,9 @@ defmodule Mint.HTTP2 do {:error, %TransportError{reason: :closed}} -> handle_closed(conn) + {:error, %TransportError{reason: :timeout} = error} -> + {:error, conn, error, []} + {:error, error} -> {:error, %{conn | state: :closed}, error, _responses = []} end