-
Notifications
You must be signed in to change notification settings - Fork 950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'getDescendentByEl' of undefined #870
Comments
I cannot recreate this using the provided code. Are you sure you updated your js assets? If you can provide a complete project to reference or more info it would be helpful. It's also possible your IEx.pry is timing out, but things worked as expected on my side. Thanks! |
I'm sorry, I did provide some files, but auth_helper.ex (ref ueberauth/guardian_phoenix#6 (comment))
this file provide user_resource by session via guardian. First mount callback execute, socket assigns successed. IEx.pry(1st.)
IEX.pry(2nd.)
mount callback is execute twice...? |
I'm seeing this as well. My mount callback is executed twice. When phx events fire before the second mount call, I get the error Router: scope "/sellers" do
live "/new", SellerLive, :new
end LiveView: defmodule MyApp.SellerLive do
use MyAppWeb, :live
def mount(_params, plug_session, socket) do
IO.inspect "MOUNT"
current_session = plug_session |> Map.get("my_app", %{}) |> Session.from_state()
{:ok, assign(socket, :current_session, current_session)}
end
...
Logs:
|
I have exactly the same problem, apparently the file \apps\myapp web\priv\static\js\app.js is not updating causing this issue ¿Does anyone fixed the problem? |
Remove |
@josevalim Done it and the problem persists |
I have a form and phx_validate just get called once I load the page. |
We see this intermittently on our CI environment on one specific end-to-end Cypress test. It's very difficult to reproduce locally. It's possible it's being triggered by a browser click event occurring before the connected mount. Our end-to-end tests run very rapidly, much faster than a user would be able to click. @josevalim I can privately share video captures of it occurring in Cypress, if useful? We will continue to see if we can reproduce locally. |
Can you please try master? We have many fixes in there. Make sure you nuke node_modules after updating. |
Thanks @josevalim, I'm afraid it's still occurring on master. I've blown away I can now reproduce locally, intermittently, inside Cypress. Here's the stack trace that Cypress produces from our compiled JS. https://gist.github.com/tomtaylor/b3a262465b8eb258647023f1c8653df3 The source map links the first line ( {
key: "getViewByEl",
value: function (e) {
var t = e.getAttribute("data-phx-root-id");
return this.getRootById(t).getDescendentByEl(e); <-- this line
}
} I can supply the code and the source map privately if useful. It looks like this is related to the debounce function. We're not using debounce in this view, but there's a throttle on a form, which the link that causes this is inside. |
I've updated the gist above to show the unobfuscated stack trace. |
I can see in Cypress that the difference between the failing runs and the passing runs is that there's no Does this attribute get set once the live socket is connected? If so, it might explain why pressing the button before the socket connection is made causes this issue. |
I can now reliably work around this by explicitly waiting for the presence of a div with a |
Oh, I see. This makes sense. In the actual application, you can't use forms and friends until phx-connected is on, because we disable the cursor and everything. But your tests were not waiting for this, which causes said errors. |
Yeah, I think Cypress does a bunch of trickery to trigger events as a user would, but I guess it's not respecting whatever mechanism LV uses to disable/enable these. Thanks for your help! |
I'm having this issue with a nested LiveView. My setup is a main page, "/foo", and several Bootstrap tabs, which can also be accessed by "/foo/bar", "/foo/baz", etc. Accessing "/foo" and clicking on the "bar" tab works fine, but directly accessing the URL "/foo/bar" causes this error. Unfortunately, it kills JS execution on the page and makes the page unusable until refreshed. Still happening with 0.14.0. |
have some issue on 0.14 |
Environment
Actual behavior
click button on phx-click, console error.
Expected behavior
If the user click button connected "phx-click", "handle_event" method execute.
app.js
new.html.leex
new.ex
ref Issue
#748
The text was updated successfully, but these errors were encountered: