mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-06 04:54:29 +08:00
Don't reconnect when WebSocket returns server error (#2264)
This commit is contained in:
parent
4665e755a3
commit
2898ee37f6
2 changed files with 8 additions and 5 deletions
|
@ -128,7 +128,14 @@ defmodule Livebook.Hubs do
|
|||
end
|
||||
|
||||
defp disconnect_hub(hub) do
|
||||
# We use a task supervisor because the hub connection itself
|
||||
# calls delete_hub (which calls this function), otherwise we deadlock.
|
||||
Task.Supervisor.start_child(Livebook.TaskSupervisor, fn ->
|
||||
# Since other processes may have been communicating
|
||||
# with the hub, we don't want to terminate abruptly and
|
||||
# make them crash, so we give it some time to shut down.
|
||||
#
|
||||
# The default backoff is 5.5s, so we round it down to 5s.
|
||||
Process.sleep(30_000)
|
||||
:ok = Provider.disconnect(hub)
|
||||
end)
|
||||
|
|
|
@ -52,7 +52,7 @@ defmodule Livebook.Teams.Connection do
|
|||
reason = LivebookProto.Error.decode(error).details
|
||||
send(data.listener, {:server_error, reason})
|
||||
|
||||
{:keep_state_and_data, {{:timeout, :reconnect}, @backoff, nil}}
|
||||
{:keep_state, data}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -60,10 +60,6 @@ defmodule Livebook.Teams.Connection do
|
|||
{:keep_state_and_data, {:next_event, :internal, :connect}}
|
||||
end
|
||||
|
||||
def handle_event({:timeout, :reconnect}, nil, _state, _data) do
|
||||
{:keep_state_and_data, {:next_event, :internal, :connect}}
|
||||
end
|
||||
|
||||
def handle_event(:info, {:loop_ping, ref}, @no_state, %__MODULE__{ref: ref} = data) do
|
||||
case WebSocket.send(data.http_conn, data.websocket, data.ref, :ping) do
|
||||
{:ok, conn, websocket} ->
|
||||
|
|
Loading…
Add table
Reference in a new issue