Skip to content

Double fetch requests for eager-loaded frames #515

@blrB

Description

@blrB

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 38b8f13). 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions