In other words, when you use handle_call, your caller (the process that calls GenServer.call) expects a reply. One can return {:noreply, state} from handle_call, but only if the reply is computed asynchronously and then sent later with GenServer.reply.
As @rvirding and @kokolegorille wrote, you have two options:
-
Return a simple reply like
{:reply, :ok, state}. This ensures thatGenServer.callwill return:okonly after the operation that you perform in theGenServercompletes. This is, generally, the best way, as it ensures that whatever you wanted to execute actually does execute. -
Alternatively, if you really don’t care about the answer, and also you don’t need to guarantee that the
GenServeractually performed the operation, you can useGenServer.castandhandle_cast.






















