Giter Site home page Giter Site logo

Comments (5)

goofansu avatar goofansu commented on May 8, 2024 1

Hi @josevalim , here is the minimal repo to reproduce: https://github.com/goofansu/live_dashboard_playground

Steps:

  1. Start server with mix phx.server
  2. Visit http://localhost:4000/dashboard
  3. No error
  4. Stop server but don't close the browser
  5. Start server with mix phx.server again, waiting for the LiveView's re-connecting from browser
  6. The error ** (ArgumentError) assign @menu not available in eex template. occurs

It seems the menu assign is not persisted in cookie. But I cannot reproduce it with {:phoenix_live_dashboard, path: "~/src/phoenix_live_dashboard"} where the phoenix_live_dashboard is on v0.1.0 branch.

from phoenix_live_dashboard.

goofansu avatar goofansu commented on May 8, 2024

Having the same problem but dashboard seems work.

The error trace
[info] Running BrightuWeb.Endpoint with cowboy 2.7.0 at 0.0.0.0:4000 (http)
[info] Access BrightuWeb.Endpoint at http://localhost:4000
[info] CONNECTED TO Phoenix.LiveView.Socket in 161µs
  Transport: :websocket
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "Gx0WDm8UHDcHT1plGSYECBIhLBQLMisryHxY9FIe_-w24C5_uVNDEpdC", "vsn" => "2.0.0"}
[error] GenServer #PID<0.527.0> terminating
** (ArgumentError) assign @menu not available in eex template.

Please make sure all proper assigns have been set. If this
is a child template, ensure assigns are given explicitly by
the parent template as they are not automatically forwarded.

Available assigns: [:flash, :inner_content, :live_action, :live_module, :socket]

    (phoenix_live_view 0.12.0) lib/phoenix_live_view/engine.ex:860: Phoenix.LiveView.Engine.fetch_assign!/2
    (phoenix_live_dashboard 0.1.0) lib/phoenix/live_dashboard/templates/layout/live.html.leex:7: anonymous fn/2 in Phoenix.LiveDashboard.LayoutView."live.html"/1
    (phoenix_live_view 0.12.0) lib/phoenix_live_view/diff.ex:221: Phoenix.LiveView.Diff.traverse/5
    (phoenix_live_view 0.12.0) lib/phoenix_live_view/diff.ex:92: Phoenix.LiveView.Diff.render/3
    (phoenix_live_view 0.12.0) lib/phoenix_live_view/channel.ex:504: Phoenix.LiveView.Channel.render_diff/2
    (phoenix_live_view 0.12.0) lib/phoenix_live_view/channel.ex:199: Phoenix.LiveView.Channel.maybe_call_mount_handle_params/4
    (phoenix_live_view 0.12.0) lib/phoenix_live_view/channel.ex:620: Phoenix.LiveView.Channel.verified_mount/4
    (phoenix_live_view 0.12.0) lib/phoenix_live_view/channel.ex:34: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 3.12) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib 3.12) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib 3.12) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:mount, Phoenix.LiveView.Channel}
State: {%{"flash" => nil, "joins" => 1, "params" => %{"_csrf_token" => "Gx0WDm8UHDcHT1plGSYECBIhLBQLMisryHxY9FIe_-w24C5_uVNDEpdC"}, "session" => "SFMyNTY.g2gDaAJhBHQAAAAHZAACaWRtAAAAFHBoeC1GZ2JZNjNnSFlEQ25iZ0ZoZAAKcGFyZW50X3BpZGQAA25pbGQACHJvb3RfcGlkZAADbmlsZAAJcm9vdF92aWV3ZAAlRWxpeGlyLlBob2VuaXguTGl2ZURhc2hib2FyZC5Ib21lTGl2ZWQABnJvdXRlcmQAGEVsaXhpci5CcmlnaHR1V2ViLlJvdXRlcmQAB3Nlc3Npb250AAAAAm0AAAAHbWV0cmljc2QAA25pbG0AAAAOcmVxdWVzdF9sb2dnZXJkAANuaWxkAAR2aWV3ZAAlRWxpeGlyLlBob2VuaXguTGl2ZURhc2hib2FyZC5Ib21lTGl2ZW4GANrsKIxxAWIAAVGA.MczQ-_m_peHABCrPDbLp_WpwlwJSW-0H0U3Ofhg_W90", "static" => "SFMyNTY.g2gDaAJhBHQAAAADZAAKYXNzaWduX25ld2pkAAVmbGFzaHQAAAAAZAACaWRtAAAAFHBoeC1GZ2JZNjNnSFlEQ25iZ0ZobgYA2uwojHEBYgABUYA.DVmNx8O6M2TN8SbWacYPrWet0mBxnzYeVYY6Z6iDQ4o", "url" => "http://localhost:4000/dashboard/nonode%40nohost"}, {#PID<0.524.0>, #Reference<0.3153342612.1519124482.123405>}, %Phoenix.Socket{assigns: %{}, channel: Phoenix.LiveView.Channel, channel_pid: nil, endpoint: BrightuWeb.Endpoint, handler: Phoenix.LiveView.Socket, id: nil, join_ref: "9", joined: false, private: %{session: %{}}, pubsub_server: BrightuWeb.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: "lv:phx-FgbY63gHYDCnbgFh", transport: :websocket, transport_pid: #PID<0.524.0>}}
[error] an exception was raised:
    ** (ArgumentError) assign @menu not available in eex template.

Please make sure all proper assigns have been set. If this
is a child template, ensure assigns are given explicitly by
the parent template as they are not automatically forwarded.

Available assigns: [:flash, :inner_content, :live_action, :live_module, :socket]

        (phoenix_live_view 0.12.0) lib/phoenix_live_view/engine.ex:860: Phoenix.LiveView.Engine.fetch_assign!/2
        (phoenix_live_dashboard 0.1.0) lib/phoenix/live_dashboard/templates/layout/live.html.leex:7: anonymous fn/2 in Phoenix.LiveDashboard.LayoutView."live.html"/1
        (phoenix_live_view 0.12.0) lib/phoenix_live_view/diff.ex:221: Phoenix.LiveView.Diff.traverse/5
        (phoenix_live_view 0.12.0) lib/phoenix_live_view/diff.ex:92: Phoenix.LiveView.Diff.render/3
        (phoenix_live_view 0.12.0) lib/phoenix_live_view/channel.ex:504: Phoenix.LiveView.Channel.render_diff/2
        (phoenix_live_view 0.12.0) lib/phoenix_live_view/channel.ex:199: Phoenix.LiveView.Channel.maybe_call_mount_handle_params/4
        (phoenix_live_view 0.12.0) lib/phoenix_live_view/channel.ex:620: Phoenix.LiveView.Channel.verified_mount/4
        (phoenix_live_view 0.12.0) lib/phoenix_live_view/channel.ex:34: Phoenix.LiveView.Channel.handle_info/2
        (stdlib 3.12) gen_server.erl:637: :gen_server.try_dispatch/4
        (stdlib 3.12) gen_server.erl:711: :gen_server.handle_msg/6
        (stdlib 3.12) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

FYI, it happens when re-connecting the liveview socket. If either "Metrics" or "Request Logger" is configured, the problem is gone.

But I cannot reproduce it with v0.1.0 branch in local:

  1. Clone phoenix_live_dashboard and checkout v0.1.0 branch
git clone [email protected]:phoenixframework/phoenix_live_dashboard.git
cd phoenix_live_dashboard
git checkout v0.1.0
  1. Modify mix.exs to use local phoenix_live_dashboard
  defp deps do
    [
      {:phoenix, "~> 1.5.0-rc.0", override: true},
      {:phoenix_pubsub, "~> 2.0"},
      {:phoenix_ecto, "~> 4.0"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:phoenix_live_dashboard, path: "~/src/phoenix_live_dashboard"},
      {:telemetry_poller, "~> 0.4"},
      {:telemetry_metrics, "~> 0.4"},
      {:gettext, "~> 0.11"},
      {:brightu, in_umbrella: true},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.1"}
    ]
  end

from phoenix_live_dashboard.

josevalim avatar josevalim commented on May 8, 2024

I tried reproducing it locally and failed. Can someone push a small app to GitHub that reproduces the issue? Also, please provide your Phoenix+Elixir versions. Thanks!

from phoenix_live_dashboard.

josevalim avatar josevalim commented on May 8, 2024

Thank you so much @goofansu . Your steps helped me reproduce it and fix a LiveView bug!

from phoenix_live_dashboard.

goofansu avatar goofansu commented on May 8, 2024

@josevalim Cool, thanks! 🧡

from phoenix_live_dashboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.