Hey there,
since I updated some dependencies 7 days ago, my live view does not work when phoenix is running in prod mode. However when I run phoenix with MIX_ENV=dev everything works fine. At the same time I switched from Elixir 1.8.x to 1.9.1 for tinkering around with “mix release”. Before those updates it worked in both environments.
I get two error message. This is the error message from the browser console:
TypeError: this.loader is null
And here the error message from the console that will be repeated untill I switch the site:
20:39:02.786 [error] GenServer #PID<0.917.0> terminating
** (MatchError) no match of right hand side value: %{"session" => "SFMyNTY.g3QAAAACZAAEZGF0YWgCYQJ0AAAABmQAAmlkbQAAAAxwaHgtUzlRQlp3OXVkAApwYXJlbnRfcGlkZAADbmlsZAAIcm9vdF9waWRkAANuaWxkAAZyb3V0ZXJkABdFbGl4aXIuSmFydmlzV2ViLlJvdXRlcmQAB3Nlc3Npb250AAAAAWQAB3VzZXJfaWRhAWQABHZpZXdkABlFbGl4aXIuSmFydmlzV2ViLkl0ZW1MaXZlZAAGc2lnbmVkbgYA2bfEjW0B.JvGoJJb2FABPHpF7_-neiEXwmnLnT4mWeOL1m-_zUO8", "static" => nil}
(phoenix_live_view) lib/phoenix_live_view/channel.ex:451: Phoenix.LiveView.Channel.verified_mount/4
(phoenix_live_view) lib/phoenix_live_view/channel.ex:28: Phoenix.LiveView.Channel.handle_info/2
(stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:711: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:mount, Phoenix.LiveView.Channel}
State: {%{"session" => "SFMyNTY.g3QAAAACZAAEZGF0YWgCYQJ0AAAABmQAAmlkbQAAAAxwaHgtUzlRQlp3OXVkAApwYXJlbnRfcGlkZAADbmlsZAAIcm9vdF9waWRkAANuaWxkAAZyb3V0ZXJkABdFbGl4aXIuSmFydmlzV2ViLlJvdXRlcmQAB3Nlc3Npb250AAAAAWQAB3VzZXJfaWRhAWQABHZpZXdkABlFbGl4aXIuSmFydmlzV2ViLkl0ZW1MaXZlZAAGc2lnbmVkbgYA2bfEjW0B.JvGoJJb2FABPHpF7_-neiEXwmnLnT4mWeOL1m-_zUO8", "static" => nil}, {#PID<0.915.0>, #Reference<0.798463413.1772879880.169990>}, %Phoenix.Socket{assigns: %{}, channel: Phoenix.LiveView.Channel, channel_pid: nil, endpoint: JarvisWeb.Endpoint, handler: Phoenix.LiveView.Socket, id: nil, join_ref: "1", joined: false, private: %{}, pubsub_server: Jarvis.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: "lv:phx-S9QBZw9u", transport: :websocket, transport_pid: #PID<0.915.0>}}
20:39:02.787 [error] an exception was raised:
** (MatchError) no match of right hand side value: %{"session" => "SFMyNTY.g3QAAAACZAAEZGF0YWgCYQJ0AAAABmQAAmlkbQAAAAxwaHgtUzlRQlp3OXVkAApwYXJlbnRfcGlkZAADbmlsZAAIcm9vdF9waWRkAANuaWxkAAZyb3V0ZXJkABdFbGl4aXIuSmFydmlzV2ViLlJvdXRlcmQAB3Nlc3Npb250AAAAAWQAB3VzZXJfaWRhAWQABHZpZXdkABlFbGl4aXIuSmFydmlzV2ViLkl0ZW1MaXZlZAAGc2lnbmVkbgYA2bfEjW0B.JvGoJJb2FABPHpF7_-neiEXwmnLnT4mWeOL1m-_zUO8", "static" => nil}
(phoenix_live_view) lib/phoenix_live_view/channel.ex:451: Phoenix.LiveView.Channel.verified_mount/4
(phoenix_live_view) lib/phoenix_live_view/channel.ex:28: Phoenix.LiveView.Channel.handle_info/2
(stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:711: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
To get more information I debugged Phoenix.LiveView.Channel.verified_mount/4 with iex. The given function paramter “params” contains no key url or params. Therefore the following line fails -> failing line.
And now the big quiz question: Why does this fail only in prod environment (MIX_ENV=prod) but not in dev environment (MIX_ENV=dev)? Or where are the keys “url” and “params”?
Here the updated dependencies: mix.lock changes