question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Double fetch requests for eager-loaded frames

See original GitHub issue

I think I found a bug.

Steps to reproduce:

  1. Create page with eager-loaded frame
  2. Create link with redirect on this page (HTTP code not important)
  3. Click on link for get redirect
  4. Watch browser network tab (or sever logs)

Example requests for turbo_frame with id: src_content: Chrome: chrome_duplicate_requests Firefox: ff_duplicate_requests

All my ‘eager-loaded frames’ were loaded twice. You can look part of my source code for ruby 3.1.0, rails 7.0.1, turbo-rails 1.0.1 here: https://gist.github.com/blrB/1b0e1d44f31df1d1c9932985471ec3b3

I think, that root case can be in line https://github.com/hotwired/turbo/blame/main/src/core/drive/visit.ts#L274 (commit https://github.com/hotwired/turbo/commit/38b8f138c1e872e8ef2ddf2da32a74916caec305). Now redirect responses use visit action replace. This visit create next trace start -> … -> loadResponse -> render -> … -> replaceBody -> sourceURLChanged -> loadSourceURL -> fetch request for frame. But fetch request already was created and rendered, before replace action had been created. I think we shouldn’t render this action twice, so we can just create this action with prams willRender: false. I tested this code, and I think it works like I expected. You can look source code here: #516

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
seanpdoylecommented, Jun 19, 2022

I believe a change like the one made in https://github.com/hotwired/turbo/pull/487 might help resolve this issue. It proposes a [loaded] attribute (there are some additional considerations regarding the name), which would expose a frame’s load state in a cache-friendly way.

0reactions
blrBcommented, Oct 21, 2022

@seanpdoyle thank you for response

are you interested in continuing to experiment with a solution?

Yes, I try to check your alternative option described in 256418fee0178ee483d82cd9bb579bd5df5a151f on next week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lazy-loaded frame - Turbo Reference
A reference of everything you can do with Turbo Frames. ... Like an eager-loaded frame, but the content is not loaded from src...
Read more >
Handling Nested HTTP Requests Using the Fetch API
In this guide, you will learn how to effectively handle the chaining of fetch calls in order to avoid nesting them. First, you...
Read more >
User notifications with Rails, Noticed, and Hotwire - Colby.so
Using the Noticed gem, Turbo Streams, and Turbo Frames to buld a real-time, in-app user notification system in Ruby on Rails.
Read more >
Image Transforms and Eager Loading - Real World Craft CMS ...
We add transforms to our images so they're the minimum needed size, and then improve performance by eager loading the images and transforms....
Read more >
Build a Table Editor with Trix and Turbo Frames in Rails
Let's build a table editor in a Rails application using ActionText's Trix editor, and use Turbo Frames to customize your table.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found