DavidVII

DavidVII

RosWeb.Endpoint module not available after compiling

I’m not sure how to best describe this issue, but I’ve started to notice this recently and I don’t know what changed that started to trigger it. Basically, anytime I save a controller or any .ex file (something that triggers the compiler it seems), I get the following error when the live reloader reloads the page:

[error] #PID<0.661.0> running RosWeb.Endpoint (connection #PID<0.660.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /live/websocket?vsn=2.0.0
** (exit) an exception was raised:
    ** (UndefinedFunctionError) function RosWeb.Endpoint.__handler__/2 is undefined (module RosWeb.Endpoint is not available)
        (ros) RosWeb.Endpoint.__handler__(%Plug.Conn{} ...) # Edited out the two args
        (phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:17: Phoenix.Endpoint.Cowboy2Handler.init/2
        (cowboy) /ros/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2
        (cowboy) /ros/deps/cowboy/src/cowboy_stream_h.erl:296: :cowboy_stream_h.execute/3
        (cowboy) /ros/deps/cowboy/src/cowboy_stream_h.erl:274: :cowboy_stream_h.request_process/3
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3


[error] #PID<0.669.0> running RosWeb.Endpoint (connection #PID<0.668.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /phoenix/live_reload/socket/websocket?vsn=2.0.0
** (exit) an exception was raised:
    ** (UndefinedFunctionError) function RosWeb.Endpoint.__handler__/2 is undefined (module RosWeb.Endpoint is not available)
        (ros) RosWeb.Endpoint.__handler__(%Plug.Conn{} ...) # Edited out the two args
        (phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:17: Phoenix.Endpoint.Cowboy2Handler.init/2
        (cowboy) ros/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2
        (cowboy) ros/deps/cowboy/src/cowboy_stream_h.erl:296: :cowboy_stream_h.execute/3
        (cowboy) ros/deps/cowboy/src/cowboy_stream_h.erl:274: :cowboy_stream_h.request_process/3
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

I’m using Phoenix LiveView, but this happens outside of LiveView files as well. The websocket errors out a bunch of times before it recovers and it reloads the page just fine. It seems that this only happens in development, and only with live reloading enabled.

I’m really at a loss and don’t even know where to begin to debug this, but this throws a TON of errors in my logs while developing and is quite frustrating.

Is anyone interested in helping me figure out what’s going on? I’m happy to share code examples, but as I said, I’m having a hard time knowing what I could share that would lead to a clue to what’s going on.

Any help would be greatly appreciated. Thank you.

Most Liked

jamesvl

jamesvl

In case others are watching this thread, it looks like Jose committed a fix for this issue, tracked in Phoenix github issue 3494

If you’re not pulling the Phoenix 1.4 branch directly, it looks like it should go out with the 1.4.10 release (probably).

jamesvl

jamesvl

I’ve been experiencing this same issue as well, and it finally annoyed me enough to start digging into it more. (I’m not using LiveView, but a regular Phoenix project.) Sometimes it seems like changes I make trigger 4-5 recompiles, and then I get lots of error messages while everything recompiles and the live reload WS endpoint can’t be reached.

I’m looking into it more and will post if I find anything.

jamesvl

jamesvl

I’ve made some progress - but this seems very OS / editor dependent right now.

Overview:

  • I’m on Linux using NeoVim and every time I write to a buffer,
  • inotifywait sees 4 changes to the file, not one.
  • Because of how the elixir FileSystem and Phoenix CodeReloader are working, four reloads of the page are attempted
  • Because these reloads take place while compiling is still in progress, error messages are logged because the Endpoint module doesn’t exist yet

Other random notes:

  • I’ve tried other editors, including nano, but still get 2-3 inotify messages per file write
  • inotify on Linux doesn’t have a “latency” parameter like the OSX filesystem does
  • I couldn’t find a way to reduce the messages in nvim - my swap and backup files and stored in different directories entirely, and setting swap and backup to be off only reduces the messages by one

I tracked it down thus far by adding the following to line 22 in deps/phoenix_live_reload/lib/phoenix_live_reload/channel.ex

      Logger.debug "Live reload event for #{path} and event #{inspect(event)}"

Where Next?

Popular in Questions Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New

Other popular topics Top

New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement