Phoenix.CodeReloader won't compile - Phoenix 1.7.7, 1.7.8

Without (knowingly) changing anything in my workflow, my Elixir/Erlang/Phoenix versions, or any dependencies etc, I suddenly started getting this error when trying to compile my new umbrella project:

== Compilation error in file lib/phxapp/endpoint.ex ==
** (ArgumentError) cannot escape #Function<0.12031047/1 in Phoenix.CodeReloader.init/1>. The supported values are: lists, tuples, maps, atoms, numbers, bitstrings, PIDs and remote functions in the format &Mod.fun/arity
    (elixir 1.15.6) src/elixir_quote.erl:505: :elixir_quote.argument_error/1
    (plug 1.15.1) lib/plug/builder.ex:344: Plug.Builder.init_module_plug/4
    (plug 1.15.1) lib/plug/builder.ex:322: anonymous fn/5 in Plug.Builder.compile/3
    (elixir 1.15.6) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plug 1.15.1) lib/plug/builder.ex:320: Plug.Builder.compile/3
    (plug 1.15.1) expanding macro: Plug.Builder.__before_compile__/1
    lib/phxapp/endpoint.ex:1: Phxapp.Endpoint (module)

(Note - I mentioned this error has started today: it also seems to be affecting only projects built today, as earlier, almost identical projects recompile just fine.)

I’m using Phoenix 1.7.7, and have been for a while. In fact, as said, my process has been rock solid for several weeks - right until this error started appearing.

I tried upgrading to 1.7.8, but that did nothing. I went back to 1.7.7, and it still persists. Only commenting out the invocation of the plug in question (in my endpoint.ex) ‘solves’ it:

 if code_reloading? do
    socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
    plug Phoenix.LiveReloader
    #plug Phoenix.CodeReloader
  end

However - I have noticed that the error seems to occur under only one project structure (of those I’ve tried). I usually build my apps via:

$ mix new app_name --umbrella
$ cd app_name/apps
$ mix phx.new.web web_app_name --no-ecto
$ mix phx.new.ecto ecto_app_name

This structure has served me well for months, right up until today. But now I get the compile error. However, if I do something like:

$ mix phx.new app_name --umbrella

or

$ mix phx.new app_name

etc, then everything works just fine? I see in the changelogs of the Phoenix repo that some changes were indeed made to Phoenix.CodeReader the day before/day of when this error started appearing - perhaps they’re the root of it?:

https://github.com/phoenixframework/phoenix/blob/main/CHANGELOG.md

Further, it seems like some other people are facing it, too:

https://github.com/phoenixframework/phoenix/issues/5598

Anyone else have any thoughts/experience with this error?

Thanks

Hi @LionelHutz first as a basic sanity check can you rm -rf _build and see if the issue persists? Beyond that, what version of Elixir are you using?

1 Like

Thanks for the reply, @benwilson512 - unfortunately removing _build didn’t change things. As for my Elixir version:

Erlang/OTP 26 [erts-14.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Elixir 1.15.6 (compiled with Erlang/OTP 26)

Happy to try any other tips or, though.

Thanks

@LionelHutz it is a bug, I will fix it. :slight_smile:

1 Like

Fixed in main.

1 Like

Great, thanks so much! Really appreciate it.

However, when I leave the reference to the Phoenix package in my deps as the default-generated:

{:phoenix, "~> 1.7.8"}

the error still appears. But if I replace it with the more specific:

{:phoenix, github: "phoenixframework/phoenix", branch: "main", override: true}

the error indeed now disappears. I’m guessing then that the update on GitHub hasn’t been propagated to Hex yet, and I should just wait for that? Or is there something else I should do to make sure the default package-reference syntax enables the fix?

Thanks!

1 Like

The fix hasn’t been made part of a versioned release yet. There aren’t new releases being made for individual bug fixes. 1.7.9 will eventually include it.

5 Likes

Ok great, thanks!

Fix was released with 1.7.9

6 Likes

Perfect, thanks