Improve messages on standalone runtime init failure (#2912)

This commit is contained in:
Jonatan Kłosko 2025-01-15 11:49:39 +01:00 committed by GitHub
parent e01abae5e8
commit f20b2c6f8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,6 +108,8 @@ defmodule Livebook.Runtime.Standalone do
port_ref = Port.monitor(port) port_ref = Port.monitor(port)
loop = fn loop -> loop = fn loop ->
# Note that the child node terminates when communication times out,
# so we should always receive either a message or :DOWN event.
receive do receive do
{:node_started, init_ref, ^child_node, child_port, primary_pid} -> {:node_started, init_ref, ^child_node, child_port, primary_pid} ->
Port.demonitor(port_ref) Port.demonitor(port_ref)
@ -122,11 +124,8 @@ defmodule Livebook.Runtime.Standalone do
{:DOWN, ^port_ref, :port, _object, reason} -> {:DOWN, ^port_ref, :port, _object, reason} ->
{:error, {:error,
"Elixir terminated unexpectedly, please check your logs for errors. Reason: #{inspect(reason)}"} "standalone runtime node (#{inspect(child_node)}) terminated unexpectedly on startup, " <>
after "please check your logs for errors. Reason: #{inspect(reason)}"}
# Use a longer timeout to account for longer child node startup.
30_000 ->
{:error, "connection timed out"}
end end
end end
@ -165,8 +164,8 @@ defmodule Livebook.Runtime.Standalone do
after after
10_000 -> 10_000 ->
IO.puts( IO.puts(
"Error: timeout during initial communication between standalone runtime" <> "Error: timeout during initial communication between standalone runtime " <>
" (node: #{inspect(node())}) and Livebook (node: #{inspect(parent_node)})." "(node: #{inspect(node())}) and Livebook (node: #{inspect(parent_node)})."
) )
:timeout :timeout