Skip to content

Commit

Permalink
Add notes and catch more GenServer.call timeout error (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
ono authored Feb 8, 2022
1 parent 4c0a87e commit dbd6f56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/amqp/application/channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ defmodule AMQP.Application.Channel do
@doc false
def get_state(name \\ :default) do
GenServer.call(get_server_name(name), :get_state)
catch
:exit, {:timeout, _} -> %{}
end

@doc """
Expand All @@ -85,6 +87,11 @@ defmodule AMQP.Application.Channel do
nil -> {:error, :channel_not_ready}
channel -> {:ok, channel}
end
catch
:exit, {:timeout, _} ->
# This would happen when the connection or channel is stuck when opening.
# See handle_info(:open, _) to understand - it can block the GenSever.
{:error, :timeout}
end

@impl true
Expand Down
4 changes: 4 additions & 0 deletions lib/amqp/application/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ defmodule AMQP.Application.Connection do
@doc false
def get_state(name \\ :default) do
GenServer.call(get_server_name(name), :get_state)
catch
:exit, {:timeout, _} -> %{}
end

@doc """
Expand All @@ -97,6 +99,8 @@ defmodule AMQP.Application.Connection do
end
catch
:exit, {:timeout, _} ->
# This would happen when the connection is stuck when opening.
# See do_open/1 to understand - it can block the GenSever.
{:error, :timeout}
end

Expand Down

0 comments on commit dbd6f56

Please sign in to comment.