Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

:invalid_mfa when calling Supervisor.start_child

Tags:

elixir

I'm trying to start a child process in Elixir, and am receiving the following error:

{:error, {:invalid_mfa, {Worker, :start_link, "MY_TEAM_ID"}}}

My supervisor code looks something like this:

DynamicSupervisor.start_child(Worker.Supervisor, {Worker, "MY_TEAM_ID"})
like image 618
AnilRedshift Avatar asked Jul 11 '26 06:07

AnilRedshift


1 Answers

From the error message, the child_spec is supposed to pass its arguments as a list. Instead it should be {:error, {:invalid_mfa, {Worker, :start_link, ["MY_TEAM_ID"]}}} (note the [] around the params)

Inside your Worker module, check your child_spec function. It should look something like this (again, note the [] around team_id):

def child_spec(team_id) do
    %{
      id: __MODULE__,
      start: {__MODULE__, :start_link, [team_id]},
      type: :worker
    }
end
like image 68
AnilRedshift Avatar answered Jul 14 '26 15:07

AnilRedshift



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!