phoenixframework / phoenix

Peace of mind from prototype to production
https://www.phoenixframework.org
MIT License
21.24k stars 2.87k forks source link

LiveView is broken with Plug 1.11.0 #4051

Closed oliverandrich closed 3 years ago

oliverandrich commented 3 years ago

Environment

Actual behaviour

I am working through a (tutorial)[https://www.leanpanda.com/blog/authentication-and-authorisation-in-phoenix-liveview/?s=09#step-3-update-the-live-views-generated-with-phxgenlive-to-perform-the-checks-ensuring-a-user-can-really-access-a-given-route] to set up a LiveView app with authentication.

Somehow my project gots updated to plug 1.11.0 and if I clean up the deps folder and remove the mix.lock file, I also get this version. Sadly plug 1.11.0 breaks LiveView if you want to implement a form. Every time you type something in the form, you get this error message on the console.

** (FunctionClauseError) no function clause matching in Phoenix.LiveView.Channel.gather_keys/2
    (phoenix_live_view 0.14.7) lib/phoenix_live_view/channel.ex:419: Phoenix.LiveView.Channel.gather_keys("", ["_csrf_token"])
    (phoenix_live_view 0.14.7) lib/phoenix_live_view/channel.ex:413: Phoenix.LiveView.Channel.decode_merge_target/1
    (phoenix_live_view 0.14.7) lib/phoenix_live_view/channel.ex:96: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 3.13.2) gen_server.erl:680: :gen_server.try_dispatch/4
    (stdlib 3.13.2) gen_server.erl:756: :gen_server.handle_msg/6
    (stdlib 3.13.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

The only solution I have found with some help from the elixir forum was to manually patch my mix.lock file, which is a rather tempting task for a learner.

"plug": {:hex, :plug, "1.10.4", "41eba7d1a2d671faaf531fa867645bd5a3dce0957d8e2a3f398ccff7d2ef017f", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad1e233fe73d2eec56616568d260777b67f53148a999dc2d048f4eb9778fe4a0"},

I also tried to pin the release in mix.exs to 1.10.4.

  defp deps do
    [
      {:bcrypt_elixir, "~> 2.0"},
      {:phoenix, "~> 1.5.6"},
      {:phoenix_ecto, "~> 4.1"},
      {:ecto_sql, "~> 3.4"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_live_view, "~> 0.14.6"},
      {:floki, ">= 0.27.0", only: :test},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:phoenix_live_dashboard, "~> 0.3 or ~> 0.2.9"},
      {:telemetry_metrics, "~> 0.4"},
      {:telemetry_poller, "~> 0.4"},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug, "== 1.10.4"},
      {:plug_cowboy, "~> 2.0"},
      {:ecto_psql_extras, "~> 0.2"},
      {:phx_gen_auth, "~> 0.5", only: [:dev], runtime: false},
      {:ecto_enum, "~> 1.4"}
    ]
  end

Then VScode marks the whole mix.exs file as an error and tells me, that some dependency problem exists. I guess cause some other module requires 1.11.0.

Or is this a bug I should report to https://github.com/phoenixframework/phoenix_live_view?

Expected behaviour

josevalim commented 3 years ago

Correct. This needs to be fixed in LV, a new release will be out soon. Also see: https://github.com/elixir-plug/plug/issues/994

chrismccord commented 3 years ago

Closed via LiveView v0.14.8