Liveview remount continuously with the follow error. What could be wrong

Hi all,
I just deployed an app to production, but it is behaving in a wild way. The liveview pages show that something went wrong, but sometimes it works well. I checked the log and found the following. It looks like it keeps trying to mount the view continuously. It is happening in most of the view.

What could I be doing wrong?
Here is how the liveview mount looks like.

  def mount(%{"person_id" => person_id}, _session, %{assigns: %{user: user}} = socket) do
    person = get_record(person_id, actor: user)

    socket
    |> assign(:record_id, nil)
    |> assign(:person, person)
    |> assign(:jobs, person.jobs)
    |> assign(:person_id, person_id)
    |> assign_mobile_header_actions()
    |> ok(layout: {ZippikerWeb.Layouts, :employee})
  end

Here are logs:

 Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "CUoCJBwyCR8DBHEeLCQHECogFxksFQk6cxZAy_k2gF5KGg4RbSeKxZNM", "_live_referer" => "undefined", "_mount_attempts" => "3", "_mounts" => "0", "_track_static" => %{"0" => "https://zippiker.com/assets/app-38549519718ce176d5d8a730d0671ae3.css?vsn=d", "1" => "https://zippiker.com/assets/app-22ba20c83c6a2e1e3c5dd785acf8c039.js?vsn=d"}, "vsn" => "2.0.0"}
20:31:55.383 [info] CONNECTED TO Phoenix.LiveView.Socket in 47µs
  Transport: :longpoll
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "CUoCJBwyCR8DBHEeLCQHECogFxksFQk6cxZAy_k2gF5KGg4RbSeKxZNM", "_live_referer" => "undefined", "_mount_attempts" => "3", "_mounts" => "0", "_track_static" => %{"0" => "https://zippiker.com/assets/app-38549519718ce176d5d8a730d0671ae3.css?vsn=d", "1" => "https://zippiker.com/assets/app-22ba20c83c6a2e1e3c5dd785acf8c039.js?vsn=d"}, "vsn" => "2.0.0"}
20:31:55.532 [info] CONNECTED TO Phoenix.LiveView.Socket in 47µs
  Transport: :longpoll
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "CUoCJBwyCR8DBHEeLCQHECogFxksFQk6cxZAy_k2gF5KGg4RbSeKxZNM", "_live_referer" => "undefined", "_mount_attempts" => "3", "_mounts" => "0", "_track_static" => %{"0" => "https://zippiker.com/assets/app-38549519718ce176d5d8a730d0671ae3.css?vsn=d", "1" => "https://zippiker.com/assets/app-22ba20c83c6a2e1e3c5dd785acf8c039.js?vsn=d"}, "vsn" => "2.0.0"}
20:31:55.719 [info] CONNECTED TO Phoenix.LiveView.Socket in 34µs
  Transport: :longpoll
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "CUoCJBwyCR8DBHEeLCQHECogFxksFQk6cxZAy_k2gF5KGg4RbSeKxZNM", "_live_referer" => "undefined", "_mount_attempts" => "3", "_mounts" => "0", "_track_static" => %{"0" => "https://zippiker.com/assets/app-38549519718ce176d5d8a730d0671ae3.css?vsn=d", "1" => "https://zippiker.com/assets/app-22ba20c83c6a2e1e3c5dd785acf8c039.js?vsn=d"}, "vsn" => "2.0.0"}
20:31:55.977 [info] CONNECTED TO Phoenix.LiveView.Socket in 34µs
  Transport: :longpoll
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "CUoCJBwyCR8DBHEeLCQHECogFxksFQk6cxZAy_k2gF5KGg4RbSeKxZNM", "_live_referer" => "undefined", "_mount_attempts" => "3", "_mounts" => "0", "_track_static" => %{"0" => "https://zippiker.com/assets/app-38549519718ce176d5d8a730d0671ae3.css?vsn=d", "1" => "https://zippiker.com/assets/app-22ba20c83c6a2e1e3c5dd785acf8c039.js?vsn=d"}, "vsn" => "2.0.0"}
20:31:58.214 [info] CONNECTED TO Phoenix.LiveView.Socket in 56µs
  Transport: :longpoll
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "CUoCJBwyCR8DBHEeLCQHECogFxksFQk6cxZAy_k2gF5KGg4RbSeKxZNM", "_live_referer" => "undefined", "_mount_attempts" => "3", "_mounts" => "0", "_track_static" => %{"0" => "https://zippiker.com/assets/app-38549519718ce176d5d8a730d0671ae3.css?vsn=d", "1" => "https://zippiker.com/assets/app-22ba20c83c6a2e1e3c5dd785acf8c039.js?vsn=d"}, "token" => "SFMyNTY.g2gDaAR3AnYxbQAAABZ0VFpZVjUzTEZ5emhVYi8rVWhPMW9BWHcRYXBwXzQwMjBAemlwcGlrZXIAABXoAAAAAGdA60ZtAAAALHBoeDpscDpxVmxPR3hXdnRNMVEzaU9BT0FIOVl3PT0xNzMzNDMwNzE1OTc2bgYASaaFmJMBYgASdQA.l9vdKwPLPB9Bo5ApQNnhnnd7ozgPrXxgi4kVZcpPd6U", "vsn" => "2.0.0"}
20:32:00.534 [info] CONNECTED TO Phoenix.LiveView.Socket in 51µs
  Transport: :longpoll

I don’t think this is necessarily an Ash-specific question, so I will move to the LiveView forums. Unless there is some kind of exception coming from the Ash code you’re calling in your LiveView (which would cause repeated mounts in this way potentially), I’m not sure what to tell you :sweat:

1 Like

Thanks for jumping in @zachdaniel. I noticed that this is happening to authenticated users, and strangely, when I clear the cache and hard-reset the browser, the issues goes away.

I am using Ash + Ash Authentication phoenix with password strategy.

:thinking: strange…I mean the first thing to look for would be client side or server side errors. Anything in the server logs? Anything in the browser errors?

1 Like

I had a logical error in the require_authenticated_user/2. I fixed it.

1 Like