Skip to content
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

assign_async fails intermittently in nested LiveViews #3614

Open
falti opened this issue Jan 3, 2025 · 1 comment
Open

assign_async fails intermittently in nested LiveViews #3614

falti opened this issue Jan 3, 2025 · 1 comment

Comments

@falti
Copy link

falti commented Jan 3, 2025

Environment

  • Elixir version (elixir -v): Elixir 1.14.2
  • Phoenix version (mix deps): phoenix 1.7.18
  • Phoenix LiveView version (mix deps): 1.0.1
  • Operating system: MacOS Sonoma 14.5 (23F79)
  • Browsers you attempted to reproduce this bug on (the more the merrier): Brave [Version 1.73.104 Chromium: 131.0.6778.204]
  • Does the problem persist after removing "assets/node_modules" and trying again? Yes/no: Yes

Actual behavior

Inside of a loop over a collection of documents I am using a nested live view using live_render/3.
Inside of that nested live view I am using assign_async/4 to loop over document pages.

I tested this both with the assign_async and explicitly with start_async using the callbacks.

In both cases only a few elements on the page will be updated in the initial load (always at the tail of the parent document live view). All other nested live views will show what's within <:loading></:loading>. The <:failed/>part is not rendered.

When navigate back and forth eventually all elements will be rendered. I also verified that all async tasks are executed.
Also if the collection rendered in the parent live view is relatively small the error doesn't reproduce.

I reverted back to use everything from my parent live view avoiding the nested live view and everything works as I would expect.

There are no errors in the server console nor in the browser console.

Expected behavior

Nested live views should allow to have async assigns and the rendering should work.

@falti falti changed the title assign_async fails eventually in nested LiveViews assign_async fails intermittently in nested LiveViews Jan 3, 2025
@SteffenDE
Copy link
Collaborator

Hey @falti,

I tried to reproduce this with a simple example: https://gist.github.com/SteffenDE/847fc145c34e3cd6a6a197a03fda965a

You can run this as elixir live_view_issue_3614.exs and visit http://localhost:5001 to see a LV and nested LV next to each other, each one running 1000 async tasks, all completing successfully.

So it would help a lot if you can provide a similar example that shows the failure.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants