fcabouat
ConsumerSupervisor failed to start child from :undef error
Hi,
I’m not able to create and test basic ConsumerSupervisor behavior.
I tried to follow the docs, but had a few issues. First one is that my child spec lacked “restart: :transient” (not present in the docs Printer example ConsumerSupervisor — gen_stage v1.3.2 : should I create an issue ?).
Here’s my code
defmodule BasicConsumerSupervisor do
defmodule MyConsumerSupervisor do
use ConsumerSupervisor
def start_link(arg) do
ConsumerSupervisor.start_link(__MODULE__, arg)
end
def init(_arg) do
children = [%{id: MyConsumer, start: {MyConsumer, :start_link, []}, restart: :transient}]
opts = [strategy: :one_for_one]
ConsumerSupervisor.init(children, opts)
end
end
defmodule MyConsumer do
def start_link(event, truc) do
Task.start_link(fn ->
IO.inspect({self(), event, truc})
end)
end
end
end
And Iex session with errors
iex(2)> {:ok, c} = BasicConsumerSupervisor.MyConsumerSupervisor.start_link([])
{:ok, #PID<0.323.0>}
iex(3)> {:ok, p} = 0..100 |> Enum.to_list |> GenStage.from_enumerable()
{:ok, #PID<0.325.0>}
iex(4)> GenStage.sync_subscribe(c, to: p)
{:ok, #Reference<0.1632678573.1983643649.222301>}
iex(5)>
18:44:26.775 [error] ConsumerSupervisor failed to start child from: {#PID<0.325.0>, #Reference<0.1632678573.1983643649.222301>} with reason: {:undef, [{MyConsumer, :start_link, [0], []}, {ConsumerSupervisor, :start_child, 3, [file: 'lib/consumer_supervisor.ex', line: 564]}, {ConsumerSupervisor, :start_events, 6, [file: 'lib/consumer_supervisor.ex', line: 424]}, {ConsumerSupervisor, :handle_events, 3, [file: 'lib/consumer_supervisor.ex', line: 413]}, {GenStage, :consumer_dispatch, 6, [file: 'lib/gen_stage.ex', line: 2329]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 637]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 711]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}
18:44:26.783 [error] ConsumerSupervisor failed to start child from: {#PID<0.325.0>, #Reference<0.1632678573.1983643649.222301>} with reason: {:undef, [{MyConsumer, :start_link, [1], []}, {ConsumerSupervisor, :start_child, 3, [file: 'lib/consumer_supervisor.ex', line: 564]}, {ConsumerSupervisor, :start_events, 6, [file: 'lib/consumer_supervisor.ex', line: 424]}, {ConsumerSupervisor, :handle_events, 3, [file: 'lib/consumer_supervisor.ex', line: 413]}, {GenStage, :consumer_dispatch, 6, [file: 'lib/gen_stage.ex', line: 2329]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 637]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 711]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}
18:44:26.800 [error] ConsumerSupervisor failed to start child from: {#PID<0.325.0>, #Reference<0.1632678573.1983643649.222301>} with reason: {:undef, [{MyConsumer, :start_link, [2], []}, {ConsumerSupervisor, :start_child, 3, [file: 'lib/consumer_supervisor.ex', line: 564]}, {ConsumerSupervisor, :start_events, 6, [file: 'lib/consumer_supervisor.ex', line: 424]}, {ConsumerSupervisor, :handle_events, 3, [file: 'lib/consumer_supervisor.ex', line: 413]}, {GenStage, :consumer_dispatch, 6, [file: 'lib/gen_stage.ex', line: 2329]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 637]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 711]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}
Any ideas what could be wrong ?
cheers,
Trending in Questions
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 3 of 3 Posts
NobbZ
There is no module named
MyConsumer, you probably meanBasicConsumerSupervisor.MyConsumer.fcabouat
You’re right, I fixed it. But I still get the same error though.
=>
…
fcabouat
Ok, I’m quite stupid : I propagated old errors into new code : took me a while before understanding the first error (ConsumerSupervisor needing restart: transient or restart: temporary), and then I had remaining errors regarding functions arity. Here this is the start_link of BasicConsumerSupervisor.MyConsumer, which was wrong : I had added a second parameter which was superfluous.
Isolating things properly (the working gen_stage/examples/consumer_supervisor.exs at main · elixir-lang/gen_stage · GitHub example helped a lot) with cold head and I could find it.
Thanx.