Hi.
I have a simple GenServer module like:
defmodule TestGenServer do
@moduledoc false
use GenServer
def start_link(options), do: GenServer.start_link(__MODULE__, options, name: __MODULE__)
@impl true
def init(_options) do
IO.inspect("INIT")
{:ok, %{}, 0}
end
def fetch(), do: GenServer.call(__MODULE__, :fetch)
@impl true
def handle_call(:fetch, _from, state) do
reply = :ok
{:reply, reply, state}
end
@impl true
def handle_info(:timeout, state) do
IO.inspect("Timeout")
{:noreply, state, 100}
end
end
I’m trying to start it on other or slave node like.
Node.start(:'test@127.0.0.1')
pa = :code.get_path |> Enum.reduce([], &([~c"-pa", &1 | &2]))
{:ok, pid, node} = :peer.start_link(%{name: :test1, host: ~c"127.0.0.1", args: pa})
{:ok, p} = :rpc.call(node, TestGenServer, :start_link, [:ok])
:rpc.call(node, TestGenServer, :fetch, [])
And last call fails with
{:badrpc, {:EXIT, {:noproc, {GenServer, :call, [TelemetryMetricsMnesia, :fetch, 5000]}}}}
If I use :rpc.cast/4
to start GenServer
everything works fine.
Is it expected behaviour for :npc.call/4
to terminate process after it returns?
I tried on Erlang 26.1.2 with Elixir 1.15.7 and Erlang 26.0.2 with Elixir 1.15.4. Both works in the same manner.