Phoenix Liveview uploads and Turbolinks issue

Hey there,

since I updated to latest liveview version (0.17.0), live uploads are no longer working after a Turbolink navigation:

  • livesocket is disconnected in turbolinks:before-visit callback
  • livesocket is connected in turbolinks:load callback

If we force refresh the page or if we disable turbolinks (data-turbolinks=false) on the link leading to the upload form, then upload is working properly.

Upload fails silently with no client or server error.

Not sure using Turbolinks and LiveView together are a supported configuration. Turbolinks messes around with the DOM and the JavaScript history API to prevent a full page load and that likely causes LiveView not to load correctly. It might be better to just keep Turbolinks disabled for any LiveView pages, and use LiveView patch/redirect instead where possible.

As for LiveView patch/redirect, aka. live navigation, that works much like Turbolinks does, so if you’re moving from one LiveView page to another, it should be even faster than TL: Live navigation — Phoenix LiveView v0.17.5

1 Like

We might indeed end up by ditching Turbolinks in favor of live navigation.

But liveview and Turbolinks were perfectly working together up to 0.15.0 (and btw upgrade to 0.17.0 was really painful with live_components breaking changes)

Yeah, but unless either the LiveView or Turbolinks team are explicitly testing for compatibility with the other, that is just accidental compatibility. Since both libraries are messing with how browser pages are loaded, any change in either library risks breaking the other. And since LV has its own navigation thing, it might not be worth the effort to support TL as well. (I’m not a member of the LV dev team, this is just my opinion)

Yeah, my LiveView apps are still on 0.16 for the same reason. Unlike the classic MVC setup where Phoenix had decades of best practise to draw on, LiveView is still a novel programming model where we’re still working to figure out how to best do things, so until we reach 1.0, APIs are subject to change. It’s challenging, but the end result will be all the better for it.