DavidVII

DavidVII OP

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.

First 10 of 13 Posts Switch mode

Nicd

Nicd

There might be a compilation error occurring (the error message would be printed before those errors), and as the module cannot be compiled, it will lead to those errors. At least that’s what it usually is for me.

DavidVII

DavidVII OP

Thanks for the reply, @Nicd!

Unfortunately, there’s no other error that is displayed before the one I posted. That error I shared is triggered like 3-4 times, then the page reloads just as expected. It’s really quite strange.

Any other ideas?

DavidVII

DavidVII OP

New development in this bug:

Going to localhost:4000 triggers the module Endpoint is not available error, but if I expose my localhost using ngrok and visit mysubdomain.ngrok.io then the problem seems to go away. This is quite strange, but I’m guessing it has something to do with the domain.

cyberwolf_ru

cyberwolf_ru

Hey! I’m getting the same behavior. Even on fresh generated app!

Did you found any solution apart from Ngrok? (ngrok trick works as well)

DavidVII

DavidVII OP

Unfortunately not. I still get the same error and I’m no closer to finding out why. I’m currently ignoring it, but it’s a huge distraction. You’re the first person I’ve heard having the same issue.

I don’t even know where to begin, but maybe we can help each other debug it. I work on my project on an almost daily basis and would love to get this resolved. I haven’t been able to reproduce it in a newly generated app.

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.

DavidVII

DavidVII OP

Good luck! I’ve spent hours trying to figure it out myself, but just haven’t been able to dig too deep due to time constraints. I’ve noticed the same thing as you too. If you look at the web console you’ll see the WS endpoint can’t be reached a bunch of times before the page reloads.

I wonder if it has to do with phoneix live reload?

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)}"
beepboop

beepboop

In my case the error is perfectly reproducible in the following scenario:

  • Create new project with default configuration: mix phx.new phoenix_test
  • Make a change to controller file, no live reload should be triggered
  • When you manually refresh page, a compile will be triggered and initial Live Reload connection to websockets will fail

I’m running Fedora, not sure if OS/Distro has any effect on it. Not sure how to fix it either, it’s quite annoying though.

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
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
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
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
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
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement