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