Skip to content

fix(mint): avoid crashes on HTTP/2 request resets#846

Merged
yordis merged 1 commit intomasterfrom
yordis/fix-mint-server-closed-request-proof-first
Apr 22, 2026
Merged

fix(mint): avoid crashes on HTTP/2 request resets#846
yordis merged 1 commit intomasterfrom
yordis/fix-mint-server-closed-request-proof-first

Conversation

@yordis
Copy link
Copy Markdown
Member

@yordis yordis commented Apr 22, 2026

  • closes Mint Adapter is failing to handle the :server_closed_request error reason #553 by anchoring the change to the live HTTP/2 request-reset behavior that originally crashed the Mint adapter
  • preserve Mint's request-scoped error for callers instead of turning that response into a FunctionClauseError inside the adapter
  • keep the regression proof at the transport level so future changes stay pinned to the reported failure mode

Copilot AI review requested due to automatic review settings April 22, 2026 05:05
@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 22, 2026

PR Summary

Medium Risk
Changes error handling in the core Mint adapter receive/reduce path and stream body enumeration, which can affect how callers observe failures and connection lifecycles under HTTP/2 resets.

Overview
Prevents the Mint adapter from crashing when Mint emits request-scoped HTTP/2 errors (e.g., server resets) by making reduce_responses/3 propagate {:error, error} from {:error, ref, error} responses and by raising those errors during body_as: :stream enumeration.

Adds end-to-end regression coverage using a real TLS Cowboy HTTP/2 server that triggers internal errors and mid-stream resets, asserting both Mint’s emitted responses and Tesla’s adapter behavior; also extends push promise coverage to validate pushed-stream responses from a live HTTP/2 server.

Reviewed by Cursor Bugbot for commit b3e5d67. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Tesla’s Mint adapter crash reported in issue #553 by ensuring Mint HTTP/2 stream reset errors (e.g. {:server_closed_request, :internal_error}) are surfaced to callers instead of causing a FunctionClauseError.

Changes:

  • Introduces Tesla.Adapter.Mint.ResponseAccumulator to reduce Mint responses while halting on request-scoped {:error, ref, error} tuples.
  • Updates the adapter receive path to use the new accumulator and return the Mint error tuple.
  • Adds regression tests, including a live Cowboy HTTP/2 reproduction that triggers an INTERNAL_ERROR stream reset.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/tesla/adapter/mint.ex Adds a response accumulator and integrates it into the Mint adapter receive loop to avoid crashes on request reset errors.
test/tesla/adapter/mint_test.exs Adds unit coverage for the accumulator plus an end-to-end HTTP/2 stream reset reproduction/regression test.
test/support/mint_internal_error_handlers.ex Adds Cowboy request/stream handlers used to reproduce the HTTP/2 reset scenario in tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/tesla/adapter/mint.ex Outdated
Comment thread test/support/mint_internal_error_handlers.ex Outdated
Comment thread test/tesla/adapter/mint_test.exs Outdated
@yordis yordis force-pushed the yordis/fix-mint-server-closed-request-proof-first branch 3 times, most recently from e7ce8f8 to 0e82fa0 Compare April 22, 2026 05:32
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 0e82fa0. Configure here.

Comment thread lib/tesla/adapter/mint.ex
@yordis yordis force-pushed the yordis/fix-mint-server-closed-request-proof-first branch 7 times, most recently from db202ba to 8079462 Compare April 22, 2026 06:22
@yordis yordis requested a review from Copilot April 22, 2026 06:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/tesla/adapter/mint.ex
Comment thread test/support/mint_internal_error_handlers.ex Outdated
Comment thread test/tesla/adapter/mint_test.exs Outdated
@yordis yordis force-pushed the yordis/fix-mint-server-closed-request-proof-first branch 2 times, most recently from 4efc3e7 to 854fe01 Compare April 22, 2026 06:57
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis force-pushed the yordis/fix-mint-server-closed-request-proof-first branch from 854fe01 to b3e5d67 Compare April 22, 2026 06:58
@yordis yordis requested a review from Copilot April 22, 2026 07:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yordis yordis merged commit 6a42469 into master Apr 22, 2026
14 checks passed
@yordis yordis deleted the yordis/fix-mint-server-closed-request-proof-first branch April 22, 2026 07:10
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.

Mint Adapter is failing to handle the :server_closed_request error reason

2 participants