-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not render cache after preloaded response #458
Do not render cache after preloaded response #458
Conversation
@seanpdoyle - can you review this PR and let me know if I need to change anything? |
async "test cache does not override response after redirect"() { | ||
await this.remote.execute(() => { | ||
const cachedElement = document.createElement("some-cached-element") | ||
document.body.appendChild(cachedElement) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it significant that this is an appended element? Could an <input>
with text typed into it suit this test as state to preserve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my experience, the browser stores <input>
text in memory, not in the DOM. Since turbo only caches DOM, testing cache through text input would not work.
Alternatively, I could add (or remove) a attribute to an existing DOM item (e.g. data-cached="true"
)
Essentially, I have to mock a scenario where the same URL is different from the first cached visit, to the follow-up new visit. Something like a <div id="flash">One Item Flash Message</div>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanpdoyle - thumbs up means you are good with the explanation or you want an update to the test with one of the suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current version works for me. Thank you for uncovering and digging into this!
@tleish do you use the iOS adapter by any chance? I'm trying to work out if this function has the same problem that this PR fixed: https://github.com/hotwired/turbo-ios/blob/fadb1f3888427a839f1e102ec5f38125f96172ba/Source/WebView/turbo.js#L116 |
@ghiculescu Yes, we do use the iOS adapter. What issue are you experiencing? |
It was a screen flicker, but it ended up being unrelated and due to us not creating a new view controller on each visit - apparently yiu really need to do that. So not this issue at all. That said... does that code I linked look like it could cause the issue this PR addresses? |
I haven't tested this particular bug on mobile, but it looks to follow the same older pattern and quite possibly has the same bug. Are you going to submit a PR to suggest an update to follow the same pattern as this MR? |
I can, but I'm not confident it's an issue yet. Do you have a test page I can use to replicate it? |
@ghiculescu - See the steps to reproduce and demo app linked in the original #447 issue |
Fix a race condition where
BrowserAdapter#visitStarted
renders cache after preloaded content is rendered.The BrowserAdapter has the following:
When
visit.issueRequest()
takes longer than 1ms, thenvisit.loadCachedSnapshot()
renders the cache first. When it renders immediately (as in a preloaded response) thenvisit.loadCachedSnapshot()
renders last.Fixes #447