-
Notifications
You must be signed in to change notification settings - Fork 346
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 deadlocks GenServer using it at handle_continue
call
#398
Comments
Can't reproduce it 😒 adapter = {Tesla.Adapter.Mint, timeout: :timer.seconds(10), mode: :passive} |
With passive mode it works great! |
I wonder why you can't reproduce, I tried in three machines here (2 with ubuntu, one with gentoo) and some versions of erlang and elixir and I was able to reproduce in every single one. Just to remove any variable from the test, I uploaded a github project which reproduces the issue, if you don't mind, can you test with it? The link is here: https://github.com/sezaru/test_tesla You only need to run |
I created a new issue in Mint github page since I was able to reproduce it using mint directly without Tesla |
Hey @alex-strizhakov talking with the Mint devs, we figured out what is happening. Basically the function defp receive_message(conn, %{mode: :active} = opts) do
receive do
message ->
HTTP.stream(conn, message)
after
opts[:timeout] -> {:error, :timeout}
end
end But if I do a A solution would be to pattern match the possible mint responses, for example: defp receive_message(conn, %{mode: :active} = opts) do
receive do
{:ssl, {:sslsocket, _, _}, _} = message ->
HTTP.stream(conn, message)
after
opts[:timeout] -> {:error, :timeout}
end
end Obviously this needs to handle all possible valid messages, but it fixes the issue for my case. |
Closing since #399 has been merged. |
Hello, if
Mint
adapter is used during GenServerhandle_continue
call, and someone calls the Genserver during it, for some reason it always fails with{:error, :unknown}
message and them deadlocks the GenServer itself.Below is a sample code to trigger it:
As you can see, we initialize the GenServer and then run
:some_call
call.:some_call
will deadlock and never return a result.Note that you need to call
:some_call
during GenServer initialization, if you call after it, it works as expected, so my recommendation is to simply copy and paste this whole code into IEX to trigger it.The text was updated successfully, but these errors were encountered: