Skip to content

fix: ensure id included in supervisor child spec#31

Open
gf3 wants to merge 1 commit intoderekkraan:mainfrom
gf3:fix/child-spec-id
Open

fix: ensure id included in supervisor child spec#31
gf3 wants to merge 1 commit intoderekkraan:mainfrom
gf3:fix/child-spec-id

Conversation

@gf3
Copy link
Copy Markdown

@gf3 gf3 commented Jan 12, 2026

If id is not set in child_spec/1 it defaults to __MODULE__ which prevents more than one instance of HighlanderPG from running. Here is the output from the added test before the fix is applied:

  1) test can start multiple HighlanderPG instances (HighlanderPGTest)
     test/highlander_pg_test.exs:150
     ** (EXIT from #PID<0.1853.0>) bad child specification, more than one child specification has the id: HighlanderPG.
     If using maps as child specifications, make sure the :id keys are unique.
     If using a module or {module, arg} as child, use Supervisor.child_spec/2 to change the :id, for example:

         children = [
           Supervisor.child_spec({MyWorker, arg}, id: :my_worker_1),
           Supervisor.child_spec({MyWorker, arg}, id: :my_worker_2)
         ]

I also captured the log output from one of the tests to make it a little less noisy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant