Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mint Adapter is failing to handle the :server_closed_request error reason #553

Open
igorrfc opened this issue Dec 8, 2022 · 1 comment

Comments

@igorrfc
Copy link

igorrfc commented Dec 8, 2022

Hi everyone! My error tracker has been alerting about this error multiple times lately:

FunctionClauseError: no function clause matching in anonymous fn/2 in Tesla.Adapter.Mint.reduce_responses/3
  File "lib/tesla/adapter/mint.ex", line 328, in anonymous fn/2 in Tesla.Adapter.Mint.reduce_responses/3
  File "lib/enum.ex", line 2468, in Enum."-reduce/3-lists^foldl/2-0-"/3
  File "lib/tesla/adapter/mint.ex", line 298, in Tesla.Adapter.Mint.receive_packet/4
  File "lib/tesla/adapter/mint.ex", line 258, in Tesla.Adapter.Mint.receive_responses/4
  File "lib/tesla/adapter/mint.ex", line 197, in Tesla.Adapter.Mint.format_response/3
  File "lib/tesla/adapter/mint.ex", line 59, in Tesla.Adapter.Mint.call/2
  File "lib/tesla/middleware/retry.ex", line 88, in Tesla.Middleware.Retry.retry/3
  File "timer.erl", line 266, in :timer.tc/3

As you can see, there is no clear information about which request exactly this error is happening, thus I can't provide a way to reproduce it. I have the arguments being passed to the reduce_responses/3 fn though:

The first one is:

{:error, #Reference<0.4006778225.3585081345.246352>, %Mint.HTTPError{reason: {:server_closed_request, :internal_error}, module: Mint.HTTP2}}

And the second apparently is the API response containing (on map format) containing a data attribute.

Any thoughts about what could be the issue there? Thanks and let me know if I can provide more information or help :D

@igorrfc igorrfc changed the title Mint Adapter is failing to handle the :server_closed_request error Mint Adapter is failing to handle the :server_closed_request error reason Dec 8, 2022
@yordis
Copy link
Member

yordis commented Dec 10, 2022

Are you in the latest version of Tesla and Mint? I will suggest verifying this is still an issue in the latest version.

It will be tricky without being able to reproduce thou.

It seems that https://github.com/elixir-tesla/tesla/blob/master/lib/tesla/adapter/mint.ex#L329-L341 may not match anybody of fn

Based on

{:error, #Reference<0.4006778225.3585081345.246352>, %Mint.HTTPError{reason: {:server_closed_request, :internal_error}, module: Mint.HTTP2}}

There is no matching for {:error ...}, so it would not work.

I am unsure if the issue is Mint Adapter or Mint Adapter combined with the Retry middleware and whatnot.

I will suggest trying to replicate it. It is hard to tell what to do and why this is happening.

Based on the error message :internal_errorspawning up some server that returns some 500s, it should hopefully work. At least, I would try that.

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

No branches or pull requests

2 participants