Double fetch requests for eager-loaded frames
See original GitHub issueI think I found a bug.
Steps to reproduce:
- Create page with eager-loaded frame
- Create link with redirect on this page (HTTP code not important)
- Click on link for get redirect
- Watch browser network tab (or sever logs)
Example requests for turbo_frame with id: src_content: Chrome: Firefox:
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:
- Created 2 years ago
- Reactions:5
- Comments:7 (6 by maintainers)
Top GitHub Comments
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.@seanpdoyle thank you for response
Yes, I try to check your alternative option described in 256418fee0178ee483d82cd9bb579bd5df5a151f on next week.