Return a tunnel timeout error when the CONNECT deadline elapses#495
Merged
Conversation
receive_response/3 recomputes the remaining timeout from the deadline on
every loop iteration and feeds it straight into the receive's after
clause. A proxy that keeps dribbling bytes of the CONNECT response until
the deadline passes mid-loop produces a negative timeout, which raises
ErlangError :timeout_value in the calling process instead of returning
{:error, %Mint.HTTPError{reason: {:proxy, :tunnel_timeout}}}. Clamp the
timeout to 0 so an elapsed deadline yields the documented error.
Also document the :tunnel_timeout option in the Proxying section; it was
previously only mentioned in the Mint.HTTPError docs.
Coverage Report for CI Build 0Coverage increased (+0.06%) to 87.945%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
whatyouhide
reviewed
Jul 21, 2026
| * `:tunnel_timeout` - the maximum time (in milliseconds) to wait for the proxy | ||
| to reply to the `CONNECT` request. If the tunnel is not established within | ||
| this time, `connect/4` returns a `Mint.HTTPError` with reason | ||
| `{:proxy, :tunnel_timeout}`. Defaults to `30_000` (30 seconds). |
Contributor
There was a problem hiding this comment.
This is missing the *Available since vX.X.X* notice.
Member
Author
There was a problem hiding this comment.
This option has been available since 0.1.0, it was just not documented.
whatyouhide
approved these changes
Jul 21, 2026
ericmj
force-pushed
the
clamp-tunnel-timeout
branch
from
July 21, 2026 16:02
82ad410 to
0bfc146
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A proxy that dribbles the CONNECT response until the tunnel deadline passes mid-loop makes
receive_response/3compute a negative timeout for itsafterclause, which raisesErlangError :timeout_valuein the calling process instead of returning{:error, %Mint.HTTPError{reason: {:proxy, :tunnel_timeout}}}. This clamps the timeout to 0 so an elapsed deadline yields the documented error, with offline regression tests (the crash reproduces deterministically with an already-elapsed deadline).Also documents
:tunnel_timeoutin the Proxying section, which was previously only mentioned in theMint.HTTPErrordocs.