RunTimeError PubSub not configured, but other suscriptions are working ok

I’m getting this error in one of 3 suscriptions that I have. I don’t understang why an specific suscriptions it’s not working but the other’s are working.

Any hints on how to solve this issue?

In order for us to help, we would need more context, preferably the error messages and even some code. That way if we see what is going on, we could provide further assistance.

1 Like

Sure. In config.exs:

config :admission, ExampleWeb.Endpoint,
  pubsub_server: Example.PubSub

In application.ex:

  def start(_type, _args) do
    children = [
      Example.Repo,
      {Phoenix.PubSub, name: Example.PubSub, fastlane: Phoenix.Channel.Server},
      ExampleWeb.Endpoint,
      {Absinthe.Subscription, ExampleWeb.Endpoint}
    ]

    opts = [strategy: :one_for_one, name: Admission.Supervisor]
    Supervisor.start_link(children, opts)
  end

A working suscription:

  object :first_suscriptions do
    field :exam_status, :exam do
      arg :exam_id, non_null(:id)
      config fn args, _ -> {:ok, topic: "exam:" <> args.exam_id} end

      trigger [:update_exam_status], topic: fn
        exam_status -> ["exam:" <> "#{exam_status.id}"]
      end
    end
  end

Non working suscription:

  object :infraction_suscriptions do

    field :new_infraction, :infraction do
      arg :room_id, non_null(:id)
      config fn args, _ -> {:ok, topic: "room:" <> args.room_id} end

      trigger [:create_infraction], topic: fn
        infraction ->
          room_id = infraction.application_id |> Exams.get_application_room
          ["room:" <> "#{room_id}"]
      end
    end
  end

The error I get is:

Elixir.RuntimeError: Pubsub not configured!

Subscriptions require a configured pubsub module.

The thing is, I should be getting the error on both suscriptions not just one, that is the weird thing.