Live reloading stopped working (phoenix 1.8-rc1, elixir 1.18, otp 27)

Live reloading stopped working (phoenix 1.8-rc1, elixir 1.18, otp 27)

For some reason, my live reloading isn’t working anymore and I have no idea why. I upgraded my phoenix app from 1.7 to 1.8-rc1. Somewhere along the way, I think its related, my live reloading stopped working.

Versions

  • phoenix: 1.8-rc1
  • elixir 1.18.3
  • erlang 27.0.3

Description

First, I checked to make sure that live debugger is connecting:

if (process.env.NODE_ENV === "development") {
  window.addEventListener(
    "phx:live_reload:attached",
    ({ detail: reloader }) => {
      console.log("🦠 'reloader attached':", "reloader attached");

Which returns 🦠 'reloader attached': reloader attached in the browser, so we are all good there.

However, I did notice that no logs are streamed to the browser even though this is set up correctly:

config :my_app, MyAppWeb.Endpoint,
  live_reload: [
    web_console_logger: true,
    patterns: [
      ~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",
      ~r"priv/gettext/.*(po)$",
      ~r"lib/my_app_web/(controllers|live|components)/.*(ex|heex)$"
    ]
  ]

As you can see from the snippet above I did try to specify another path because I thought that this might be the issue but it made no difference.

What is also strange is that any time I change a file all I see is this in the console:

Done in 2ms

However, I liveview doesn’t refresh the page, I see no re-compilation (was that Done message the recompilation?).

other things I have tried

i tried the things listed below but didn’t have any success:

  1. upgrade/downgrade to different elixir version
  2. upgrade/downgrade to other phoenix 1.8 rc version
  3. try a different file watching type (like :fs_event)
  4. checked and made sure that my inotify allows more watchers

Does anybody have any idea what could cause this behaviour? I did try to reboot my computer and it appeared to work again, so perhaps it’s a local issue? I’m running on ubuntu 24.04.

This line is incorrect - it will only reload files in the root my_app_web folder, not any subdirectories. (And the wildcard needs to be fixed)

It should be eg. ~r"lib/my_app_web/**/.*(ex|heex)$".

4 Likes

I’m sry my post was confusing. It also didn’t work with the commented out line. I updated the post.

The actual regex that worked was this: ~r{lib/my_app_web/.*\.(?:ex|heex)$}