fix(mint): avoid failing large HTTP/2 uploads#842
Conversation
yordis
commented
Apr 18, 2026
- Large HTTP/2 uploads currently fail once the request body exceeds Mint's flow-control window.
- Streamed HTTP/2 uploads can crash instead of recovering when window updates arrive mid-request.
- Tesla should handle larger HTTP/2 request bodies without forcing callers to fall back to HTTP/1.
PR SummaryMedium Risk Overview Also propagates any response data received during upload into Reviewed by Cursor Bugbot for commit e71334b. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
This PR updates the Mint adapter to support large HTTP/2 request bodies by streaming uploads and respecting HTTP/2 flow-control windows, preventing failures/crashes on large or streamed uploads.
Changes:
- Add HTTP/2-aware request-body streaming that waits for flow-control window updates and splits chunks accordingly.
- Thread an accumulated “early response” accumulator through the request/response pipeline so window updates (and any early response frames) can be processed mid-upload.
- Add regression tests for large HTTP/2 uploads (binary body and streamed body).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
lib/tesla/adapter/mint.ex |
Streams HTTP/2 request bodies (including previously non-streaming iodata) and waits for flow-control window before writing chunks. |
test/tesla/adapter/mint_test.exs |
Adds tests covering large HTTP/2 uploads and helpers to generate/verify posted payloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
lib/tesla/adapter/mint.ex:322
receive_headers_and_status/4always callsreceive_packet/4before checking whetheraccalready contains:statusand:headers. Sinceacccan now be pre-populated from request-body streaming (e.g., while waiting for HTTP/2 window updates), this can cause an unnecessary extra receive and potentially block/timeout even though the headers/status are already available. Add a fast-path that returns immediately whenaccalready has both keys.
defp receive_headers_and_status(conn, ref, opts, acc) do
with {:ok, conn, acc} <- receive_packet(conn, ref, opts, acc) do
case acc do
%{status: _status, headers: _headers} -> {:ok, conn, acc}
# if we don't have status or headers we try to get them in next packet
_ -> receive_headers_and_status(conn, ref, opts, acc)
end
lib/tesla/adapter/mint.ex:300
receive_responses/4now accepts an initialacc, but it still unconditionally callsreceive_packet/4first. Ifaccalready contains:done(or all response data) from earlier receives during HTTP/2 upload flow-control handling, this will wait for an extra packet and may block/timeout. Consider checkingacc[:done](and runningcheck_data_size/3) before attempting anotherreceive_packet/4call.
defp receive_responses(conn, ref, opts, acc) do
with {:ok, conn, acc} <- receive_packet(conn, ref, opts, acc),
:ok <- check_data_size(acc, conn, opts) do
if acc[:done] do
if opts[:close_conn], do: {:ok, _conn} = close(conn)
{:ok, acc}
else
receive_responses(conn, ref, opts, acc)
end
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
55a397e to
0b0486c
Compare
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ff091ff. Configure here.
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
