Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I get ** (EXIT) bad return value: :ok

Tags:

elixir

I need to let a GenServer monitor a task, thus, I do:

GenServer.call(server_pid, {:monitor_task, self()})

in server:

def handle_call({:monitor_task, task_pid}, _from, state) do
  ref = Process.monitor(task_pid)
  {:reply, ref, state}
end

however, I get error:

** (stop) exited in: GenServer.call(#PID<0.768.0>, {:monitor_task, #PID<0.849.0>}, 5000)
    ** (EXIT) bad return value: :ok

Any idea?

like image 593
simo Avatar asked Dec 08 '25 07:12

simo


1 Answers

The handle_info callbacks with calls to Logger need to return {:noreply, state} or {:stop, reason, state}, but the calls to Logger return :ok, which is an invalid return value for the callback, and is what caused the error you are seeing.

like image 84
bitwalker Avatar answered Dec 10 '25 04:12

bitwalker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!