diff --git a/lib/livebook/teams/connection.ex b/lib/livebook/teams/connection.ex index 131cbb8b4..3c46c87bc 100644 --- a/lib/livebook/teams/connection.ex +++ b/lib/livebook/teams/connection.ex @@ -97,7 +97,7 @@ defmodule Livebook.Teams.Connection do {:keep_state, data} - {:server_error, conn, websocket, reason} -> + {:error, conn, websocket, reason} -> send(data.listener, {:connection_error, reason}) data = %__MODULE__{data | http_conn: conn, websocket: websocket} diff --git a/lib/livebook/teams/web_socket.ex b/lib/livebook/teams/web_socket.ex index 4898477c7..d5bdaabc5 100644 --- a/lib/livebook/teams/web_socket.ex +++ b/lib/livebook/teams/web_socket.ex @@ -118,15 +118,15 @@ defmodule Livebook.Teams.WebSocket do """ @spec disconnect(conn(), websocket() | nil, ref()) :: {:ok, conn(), websocket() | nil} - | {:error, conn() | websocket(), term()} + | {:error, conn(), websocket(), term()} def disconnect(conn, nil, _ref) do {:ok, conn} = Mint.HTTP.close(conn) {:ok, conn, nil} end def disconnect(conn, websocket, ref) do - with {:ok, conn, websocket} <- send(conn, websocket, ref, :close), - {:ok, conn} <- Mint.HTTP.close(conn) do + with {:ok, conn, websocket} <- send(conn, websocket, ref, :close) do + {:ok, conn} = Mint.HTTP.close(conn) {:ok, conn, websocket} end end @@ -139,7 +139,7 @@ defmodule Livebook.Teams.WebSocket do """ @spec receive(conn(), ref(), websocket(), term()) :: {:ok, conn(), websocket(), list(binary())} - | {:server_error, conn(), websocket(), String.t()} + | {:error, conn(), websocket(), String.t()} def receive(conn, ref, websocket, message \\ receive(do: (message -> message))) do with {:ok, conn, [{:data, ^ref, data}]} <- Mint.WebSocket.stream(conn, message), {:ok, websocket, frames} <- Mint.WebSocket.decode(websocket, data), @@ -150,10 +150,10 @@ defmodule Livebook.Teams.WebSocket do handle_disconnect(conn, websocket, ref, response) {:error, conn, exception} when is_exception(exception) -> - {:server_error, conn, websocket, Exception.message(exception)} + {:error, conn, websocket, Exception.message(exception)} {:error, conn, exception, []} when is_exception(exception) -> - {:server_error, conn, websocket, Exception.message(exception)} + {:error, conn, websocket, Exception.message(exception)} end end