collegeimprovements

collegeimprovements

Any JS command, push_patch etc are not working and giving the following error:

live_socket.js:377 Uncaught TypeError: Cannot read properties of null (reading 'el')
    at LiveSocket.replaceMain (live_socket.js:377:60)
    at live_socket.js:748:12
    at LiveSocket.withPageLoading (live_socket.js:718:23)
    at LiveSocket.historyRedirect (live_socket.js:747:10)
    at Object.exec_navigate (js.js:58:21)
    at js.js:17:22
    at Array.forEach (<anonymous>)
    at js.js:16:40
    at Array.forEach (<anonymous>)
    at Object.exec (js.js:12:14)

I’m having the following error when I try to apply push_patch.

** (ArgumentError) cannot push_patch/2 to 
%URI{authority: nil, fragment: nil, host: "localhost", path: "/events/de98359c-9b32-4197-82f0-fa7b2e283646", port: 4000, query: nil, scheme: "http", userinfo: nil}
because the given path does not point to the current root view APIWeb.Ev.Index`

Relevant handle_event code:

 @impl true
  def handle_event("debug", %{"event" => event_guid} = _params, socket) do
    socket
    |> push_patch(to: "/events/#{event_guid}")
    |> noreply_socket()
  end

push_navigate works but it takes 10 seconds while normal anchor tag just works instantaneously.

What can I try here ?

LiveView Version: 0.18.16
Phoenix Version: 1.16

Showing Posts 1 to 4

mcrumm

mcrumm

Phoenix Core Team

Here are the rules around LiveView navigation:

  1. Patch is only for modifying the URL and staying on the current LiveView process. It only works for links to the current LiveView.

  2. Navigate is to move between routes in the same live_session block in your Router. It can also be used to tear down the current LiveView process and start a new one.

Note that if you do not have any explicit live_session blocks in your Router then all live routes are in the default live session.

  1. Href is for everything else.

The slowness you are experiencing with navigate is all of the extra round-trips the client must do because the server returns errors on the invalid navigate call.

Edit: early submit :slight_smile:

collegeimprovements

collegeimprovements OP

Hi @mcrumm
Thanks a lot for your reply :blush:

Yes, both the live_views are in same route in same block in same live_session.

Even with errors it works after 10 seconds. I don’t see any exception as well. I see logs on console after 5-6 seconds.

I’ve also added the browser console error to the original question.

mcrumm

mcrumm

Phoenix Core Team

Someone reported a similar issue recently and it was resolved by making sure all dependencies were up-to-date, including making sure to rebuild client assets:

Does any of that advice apply in your case?

collegeimprovements

collegeimprovements OP

I nuked all the deps and reinstalled them and it fixed it.
Thanks a lot for your help :blush:

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
csmr
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley: Mutonex gamedesign was finish...
New
Stef-Verniers
Hello I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
kip
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews