Turbo Drive, Frames and Streams: a reference written by reading the source

The Turbo docs explain Drive, Frames and Streams separately and never say what connects them or which one to reach for. I wrote the reference I wanted when I started, and checked every claim against the source of Turbo 8.0.23 and turbo-rails 2.0.23 instead of the documentation.

What that turned up, none of it in the docs:

  • turbo:before-cache is governed by the visit’s snapshot policy, not by the renderer. Morphing does not remove the event, contrary to what is written almost everywhere, and to what I had written myself. What skips it is a broadcast-driven refresh, because Session#refresh hard-codes shouldCacheSnapshot: false. That is the global teardown hook most Rails apps have used since Turbolinks, so the cleanup code works all through development and stops the day a second tab writes.
  • Action Cable never replays broadcasts missed while the socket was down. No error, no event. The page just stays stale.
  • idiomorph falls back from moveBefore to insertBefore on browsers that lack it, and all of WebKit lacks it, which is why a class of morphing bugs only reproduces on Apple browsers.

Source links pinned to the version tags, four diagrams, a debugging checklist and a symptom index at the end. Happy to be corrected on anything in there.

3 Likes

Wow Nathan — super impressive deep-dive into all things Turbo!

1 Like

Thanks! Hope it will help people using Turbo as its maximum and see how it can replace lots of JS frameworks. :wink:

1 Like