Skip to content

Don't close the connection on a receive timeout - #486

Merged
ericmj merged 4 commits into
elixir-mint:mainfrom
keathley:dont-close-socket-on-recv-timeout
Sep 27, 2026
Merged

ericmj merged 4 commits into
elixir-mint:mainfrom
keathley:dont-close-socket-on-recv-timeout

Conversation

@keathley

@keathley keathley commented May 4, 2026

Copy link
Copy Markdown
Contributor

Its often useful to be able to test that a connection has no data waiting on it like recv(socket, 0, 0). This PR handles the timeout error and returns it to the caller, rather than defaulting to closing the connection.

@ericmj

ericmj commented May 4, 2026

Copy link
Copy Markdown
Member

CI found a failing test for this.

Is it clear from the API when Mint closes a connection on errors and when it doesn't or should we document this?

@whatyouhide

Copy link
Copy Markdown
Contributor

To Eric's comment I think yes we should. I feel it would be pretty confusing to not know that, and while I think not closing on timeouts is reasonable I also want to make sure we loudly document that.

@keathley

keathley commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@whatyouhide That makes sense to me. I should have time to fix tests and update docs later today.

The HTTP/2 test still expected a timeout to close the connection, and
HTTP/1 had no test for it.
A recv/3 timeout now leaves the connection open, while other errors from
recv/3 and stream/2 can close it.
@ericmj
ericmj merged commit 6aeb6e9 into elixir-mint:main Sep 27, 2026
3 checks passed
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.

3 participants