From 0d0efec0a954935012d3da0b576c58c5358c3bce Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Wed, 27 Nov 2024 11:13:01 -0500 Subject: [PATCH] fix: enable remote node beacon autoload --- lib/beacon/live_admin/cluster.ex | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/beacon/live_admin/cluster.ex b/lib/beacon/live_admin/cluster.ex index 7033e1b5..b5de0203 100644 --- a/lib/beacon/live_admin/cluster.ex +++ b/lib/beacon/live_admin/cluster.ex @@ -68,9 +68,17 @@ defmodule Beacon.LiveAdmin.Cluster do end node = pick_node(nodes) + enable_beacon_autoload(site, node) do_call(site, node, mod, fun, args) end + # Before a function call is made to the remote node, + # we need to enable Beacon's ErrorHandler (module autoload) + # because that call might depend on modules that have not been loaded yet. + defp enable_beacon_autoload(site, node) do + do_call(site, node, Beacon.ErrorHandler, :enable, [site]) + end + defp do_call(site, node, mod, fun, args) do if node == Node.self() do apply(mod, fun, args)