Commit 45be1fe0 authored by rinpatch's avatar rinpatch

ConnectionPool: fix gun open errors being returned without an error tuple

When gun shuts down due to the host being unreachable, the worker
process shuts down with the same shutdown reason since they are linked.
Gun doesn't have error tuples in it's shutdown reason though, so we need
to handle it in get_conn.

Closes #2008
parent 3a6a4dd7
Pipeline #29300 passed with stages
in 14 minutes and 47 seconds
......@@ -10,6 +10,7 @@ def children do
@spec get_conn(URI.t(), keyword()) :: {:ok, pid()} | {:error, term()}
def get_conn(uri, opts) do
key = "#{uri.scheme}:#{}:#{uri.port}"
......@@ -54,12 +55,14 @@ defp get_gun_pid_from_worker(worker_pid, register) do
{:DOWN, ^ref, :process, ^worker_pid, reason} ->
case reason do
{:shutdown, error} -> error
{:shutdown, {:error, _} = error} -> error
{:shutdown, error} -> {:error, error}
_ -> {:error, reason}
@spec release_conn(pid()) :: :ok
def release_conn(conn_pid) do
# :ets.fun2ms(fn {_, {worker_pid, {gun_pid, _, _, _}}} when gun_pid == conn_pid ->
# worker_pid end)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment