patreeceeo

patreeceeo

My phoenix app starts up fine, but as soon as I modify any elixir source files the above error begins to occur repeatedly. This is the reason it gives:

{:undef, [{MusicJamGameWeb.RoomChannel, :child_spec, [{MusicJamGameWeb.Endpoint, {pid<0.1281.0>, reference<0.623636450.1826357254.163247>}}], }, {Phoenix.Channel.Server, :join, 4, [file: ‘lib/phoenix/channel/server.ex’, line: 24]}, {Phoenix.Socket, :handle_in, 4, [file: ‘lib/phoenix/socket.ex’, line: 598]}, {Phoenix.Endpoint.Cowboy2Handler, :websocket_handle, 2, [file: ‘lib/phoenix/endpoint/cowboy2_handler.ex’, line: 145]}, {:cowboy_websocket, :handler_call, 6, [file: ‘/home/patrick/Code/music_jam_game/deps/cowboy/src/cowboy_websocket.erl’, line: 528]}, {:cowboy_http, :loop, 1, [file: ‘/home/patrick/Code/music_jam_game/deps/cowboy/src/cowboy_http.erl’, line: 257]}, {:proc_lib, :init_p_do_apply, 3, [file: ‘proc_lib.erl’, line: 226]}]}

So far I’ve just been following the guide on using channels (Channels — Phoenix v1.8.8) trying to get a channel up and running. I’ll push my code to GH in case that helps. Also possibly unrelated but the messages pushed on to the channel by the JS are not being received in my handle_in callback. I’m stumped.

Showing Posts 1 to 9

beepbeepbopbop

beepbeepbopbop

Could be off but check your channel module name in GH: (https://github.com/patreeceeo/music_jam_server/blob/main/lib/music_jam_game_web/channels/room_channel.ex#L1)

HelloWeb.RoomChannel != MusicJamGameWeb.RoomChannel

The clue was the module name in user_socket.ex: MusicJamGameWeb.RoomChannel,.

patreeceeo

patreeceeo OP

That was certainly an issue but alas still seeing the above issues after fixing that.

beepbeepbopbop

beepbeepbopbop

Are you sure? I’ve pulled down your repository, updated room_channel.ex and the problem goes away.

patreeceeo

patreeceeo OP

Yes, I’m sure.

Just curious if you were able to reproduce the issue? since “goes away” implies it was there. Please note the error doesn’t appear right away. I haven’t determined exactly what triggers it, but it takes some time (less than a minute) and/or interaction before it starts.

I’m going to start over with an earlier version of Elixir (using 1.13 now) and hope that I don’t run in to this again.

patreeceeo

patreeceeo OP

Also I’ve noticed a couple similar error reports around the internet. For one, the root cause had to do with the Elixir linter Vim plugin. For the other, the user had “an extra redirect.” Neither of these cases seem to apply here.

patreeceeo

patreeceeo OP

Also I’m using

  • Phoenix 1.6.7
  • Elixir 1.13
  • Erlang 24.2.1
  • Ubuntu 20.04.1
  • x86_64
patreeceeo

patreeceeo OP

FWIW I started a fresh new project, channels are working and the error is gone. I probably klutzed something, but I also switched to Elixir 1.12. Later I’ll try again with 1.13 just in case.

patreeceeo

patreeceeo OP

To my surprise, trying this same procedure again with Elixir 1.13 reproduced the same error message. I spun up a new project with phx_new, followed the official Channels guide, and the error started immediately. I pushed the code here: GitHub - patreeceeo/cowboy-opaque-error-min-repro: I believe this to be a minimal reproduction of a crash that occurs in Cowboy with correct (?) Phoenix code on Elixir 1.13 · GitHub. It wouldn’t be so bad if the error actually gave some useful info. Instead of a human-friendly message I just see :undef.

Here’s the error message again:

[error] Ranch listener MusicJamServerWeb.Endpoint.HTTP had connection process started with :cowboy_clear:start_link/4 at #PID<0.5779.0> exit with reason: {:undef, [{MusicJamServerWeb.RoomChannel, :child_spec, [{MusicJamServerWeb.Endpoint, {#PID<0.5779.0>, #Reference<0.3249608392.111935491.56526>}}], []}, {Phoenix.Channel.Server, :join, 4, [file: 'lib/phoenix/channel/server.ex', line: 24]}, {Phoenix.Socket, :handle_in, 4, [file: 'lib/phoenix/socket.ex', line: 598]}, {Phoenix.Endpoint.Cowboy2Handler, :websocket_handle, 2, [file: 'lib/phoenix/endpoint/cowboy2_handler.ex', line: 145]}, {:cowboy_websocket, :handler_call, 6, [file: '/home/patrick/Code/music_jam_server/deps/cowboy/src/cowboy_websocket.erl', line: 528]}, {:cowboy_http, :loop, 1, [file: '/home/patrick/Code/music_jam_server/deps/cowboy/src/cowboy_http.erl', line: 257]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 226]}]}
beepbeepbopbop

beepbeepbopbop

I’ve pulled your repo down as is and it fails, but once I add the channel module definition, it works as intended. In your reproduction repo, your channel module does not exist and any attempt to join a channel should fail. In fact, if you read your error message carefully, you can actually guess what it’s trying to do. Now, it does require some experience, but I can walk you through my thought process.

[error] Ranch listener MusicJamServerWeb.Endpoint.HTTP had connection process started with :cowboy_clear:start_link/4 at #PID<0.5779.0> exit with reason: {:undef, [{MusicJamServerWeb.RoomChannel, :child_spec, [{MusicJamServerWeb.Endpoint, {#PID<0.5779.0>, #Reference<0.3249608392.111935491.56526>}}], []}, {Phoenix.Channel.Server, :join, 4, [file: 'lib/phoenix/channel/server.ex', line: 24]}, {Phoenix.Socket, :handle_in, 4, [file: 'lib/phoenix/socket.ex', line: 598]}, {Phoenix.Endpoint.Cowboy2Handler, :websocket_handle, 2, [file: 'lib/phoenix/endpoint/cowboy2_handler.ex', line: 145]}, {:cowboy_websocket, :handler_call, 6, [file: '/home/patrick/Code/music_jam_server/deps/cowboy/src/cowboy_websocket.erl', line: 528]}, {:cowboy_http, :loop, 1, [file: '/home/patrick/Code/music_jam_server/deps/cowboy/src/cowboy_http.erl', line: 257]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 226]}]

There are two halves of these error that are important to us:

:undef, [{MusicJamServerWeb.RoomChannel, :child_spec, [{MusicJamServerWeb.Endpoint, {#PID<0.5779.0>, #Reference<0.3249608392.111935491.56526>}}], []},

and then every under it. What this looks like is a trace, specifically a function trace. You can tell since the output reads like a MFA (module-function-arguments). MFA are typically used with apply/3, so things like apply(String, :at, ["example", 2]) are used for somewhat dynamic calls. Now, take a look at first line:

{MusicJamServerWeb.RoomChannel, :child_spec, [{MusicJamServerWeb.Endpoint, {#PID<0.5779.0>, #Reference<0.3249608392.111935491.56526>}}]

This is definitely a MFA like structure, a module, a function atom and the leading arguments. So for one, if we assume that this is the case, the module MusicJamServerWeb.RoomChannel must exist, but it does not in your repository. Furthermore, the :child_spec function is critically important in Erlang; it defines the specification to start child processes. With that being said, we can check the Phoenix socket code for this behaviour: phoenix/lib/phoenix/channel/server.ex at v1.6 · phoenixframework/phoenix · GitHub

Here the channel is expected to have a function child_spec/1, but since the module is undefiined, you’ll run into the exact problem you have. This can easily be replicated here:

iex(2)> apply(DoesNotExist, :hello, [])
** (UndefinedFunctionError) function DoesNotExist.hello/0 is undefined (module DoesNotExist is not available)
    DoesNotExist.hello()

If you go back to the Phoenix code, it attempts to start the child process based off that child specification call, but since you’re trying to call a function that doesn’t exist, it outright fails.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
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
spammy
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
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
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
rahultumpala
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 Top

JesseHerrick
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews