mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-20 02:16:37 +08:00
Improve errors on reconnecting Mix runtime (#837)
This commit is contained in:
parent
54ceaac551
commit
d5d4e739d1
3 changed files with 19 additions and 5 deletions
|
@ -83,9 +83,23 @@ defmodule Livebook.Runtime.MixStandalone do
|
|||
|
||||
init_async(project_path, emitter)
|
||||
|
||||
await_init(ref, [])
|
||||
end
|
||||
|
||||
defp await_init(ref, outputs) do
|
||||
receive do
|
||||
{:emitter, ^ref, {:ok, runtime}} -> {:ok, runtime}
|
||||
{:emitter, ^ref, {:error, error}} -> {:error, error}
|
||||
{:emitter, ^ref, message} -> message
|
||||
end
|
||||
|> case do
|
||||
{:ok, runtime} ->
|
||||
{:ok, runtime}
|
||||
|
||||
{:error, error} ->
|
||||
message = IO.iodata_to_binary([error, ". Output:\n\n", Enum.reverse(outputs)])
|
||||
{:error, message}
|
||||
|
||||
{:output, output} ->
|
||||
await_init(ref, [output | outputs])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -98,7 +112,7 @@ defmodule Livebook.Runtime.MixStandalone do
|
|||
into: output_emitter
|
||||
) do
|
||||
{_callback, 0} -> :ok
|
||||
{_callback, _status} -> {:error, "running mix #{task} failed, see output for more details"}
|
||||
{_callback, _status} -> {:error, "running mix #{task} failed"}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -741,7 +741,7 @@ defmodule LivebookWeb.SessionLive do
|
|||
case Runtime.duplicate(runtime) do
|
||||
{:ok, new_runtime} ->
|
||||
Session.connect_runtime(socket.assigns.session.pid, new_runtime)
|
||||
socket
|
||||
clear_flash(socket, :error)
|
||||
|
||||
{:error, message} ->
|
||||
put_flash(socket, :error, "Failed to setup runtime - #{message}")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<main role="main" class="flex-grow flex flex-col h-screen">
|
||||
<div class="fixed right-8 bottom-5 z-50 flex flex-col space-y-3">
|
||||
<div class="fixed right-8 bottom-5 z-50 flex flex-col space-y-3 max-h-[80%] overflow-y-auto tiny-scrollbar">
|
||||
<%= if live_flash(@flash, :info) do %>
|
||||
<div class="shadow-custom-1 max-w-2xl flex items-center space-x-3 rounded-lg px-4 py-2 border-l-4 rounded-l-none border-blue-500 bg-white text-gray-600 hover:bg-gray-50 hover:text-gray-500 cursor-pointer" role="alert"
|
||||
phx-click="lv:clear-flash"
|
||||
|
|
Loading…
Add table
Reference in a new issue