Blog

Elixir: (EXIT) time out en GenServer.call

Elixir: (EXIT) time out en GenServer.call

Este código:
  def handle_call({:kickoff, worker_count}, _from, _state) do
    1..worker_count
    |> Enum.each(fn worker_index -> Sukui.Fetcher.Supervisor.add_worker(worker_index) end)
    { :noreply, worker_count }
  end
Causaba este error:
** (exit) exited in: GenServer.call(FetcherLauncher, {:kickoff, 5}, 5000)
    ** (EXIT) time out
    (elixir) lib/gen_server.ex:924: GenServer.call/3
    (sukui) lib/sukui/link_finder.ex:19: Sukui.LinkFinder.process_uris/1
5000 son milisegundos de timeout. Había cambiado de handle_cast a handle_call y se me había olvidado cambiar el retorno (penúltima línea):
  def handle_call({:kickoff, worker_count}, _from, _state) do
    1..worker_count
    |> Enum.each(fn worker_index -> Sukui.Fetcher.Supervisor.add_worker(worker_index) end)
    { :reply, worker_count, worker_count }
  end