Debugging turbo_frame replacement failures

Hi all,

I’m debugging turbo frames.


When clicking on a link inside a turbo_frame, sometimes the response from the server is loaded as a full page load. For some reason, Turbo is not getting the response and putting it in the frame.

After a lot of debugging, this is fixed by putting an explicit 'data-turbo-frame' attribute on the links inside the turbo_frame, but this makes me extremely uncomfortable. I’d like to understand what is going wrong.

The code structure is as follows

turbo_frame_tag 'uploaded_files_table' do
  # ...
  # a series of filter links
  = link_to uploaded_files_path(filter: filter) do # ...

  # a series of sort links
  = link_to uploaded_files_path(filter: filter, column: column) do


  • The relevant turbo_frame tag is in one and only one partial, the same partial that creates all these links, and the partial that is rendered in the responses, so that eliminates lots of potential code bugs. There is no logic around generating the turbo_frame_tag that would lead to it sometimes not appearing.
  • I’ve verified there is never more than one <turbo-frame id="uploaded_files_table"> in the generated html by inspecting the html.
  • This never happens in local development. I tried 120 page refreshes and couldn’t trigger it.
  • This happens on 60%-ish of page loads in staging. On a page load, if Turbo works, it will work forever. But 60%-ish of the time, Turbo doesn’t work to replace this particular turbo frame.
  • I removed all app machines except one, so I’m mostly certain I’m always getting the same code.
  • If it is going to fail, waiting 5 seconds after reloading the page before any interaction does not change the 30% percentage.
  • I can’t detect any differences in the html between when it works and doesn’t work.
  • There are no errors in the console, no errors in the network tab (all loads are status: 200 except the turbo stream which is 101).
  • When it navigates to a new page, before clicking the link, I verified Turbo is present by pasting window.Turbo into console. The object exists.
  • Manually inspecting the page shows that the turbo_frame is always present in the page, and the turbo_frame is always present in the response.
  • This occurs w/ rails / turbo-rails 1.5.0 and rails 7.1.3 / turbo-rails 2.0.5


Any suggestions on where I start debugging this? And to be clear, the reason I’m proceeding w/ debugging after a fix (putting the unnecessary data-turbo-frame in the links) is this feels like something is unhappy in the code, either ours or Turbo, and it will come back to bite me if I ignore it.

Thank you all in advance for any ideas.

Update: it’s Heap Analytics. Whatever they’re doing is monkeying with the js stack.

Working in local is unrelated; we don’t insert heap in development mode to preserve quota.

Nothing to add, just wanted to thank you for closing the loop on it for future readers. And good job on not just accepting a solution because “it works”, definitely the right instinct. :+1: