Fix theme serve
hot reload when there are many tabs active
#1860
Conversation
Hey @macournoyer! :) As the PR description mentions, this PR still needs some enhancements. I believe we need to keep 1. Clean based on page content matches
2. Clean based on timestampsWe could clean What do you think about these approaches? (I personally prefer the second one 🧐). |
Thank you for the awesome clues, @macournoyer! 🚀 Thinking about the coupling between the What if we pass the modified files ( For now, we could merge the files from the new parameter and What do you think about this approach? |
@macournoyer, I've updated the PR with a draft of the idea above for clarifying it. My first implementation relied on a query parameter, but I've changed it to a cookie to keep it more transparent for users. |
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.
I think my brain is fried... I understand why it works, it kind of mimics a delay, right?
I'm not sure if this is a hack, or if a real delay should be used.
Code looks good, so I'm trusting your on reasoning behind this! 🎄 🍸
Thanks for the review, @macournoyer! 🚀 The delay is not so significant, as we redefine the The nice thing is that now we've empowered the client to update the templates parameter (and we may drop the Thanks again for the review! I've added the missing unit tests to merge it 😊 |
WHY are these changes introduced?
When users have two tabs active and perform a change in some liquid file, both tabs get refreshed; however, only one gets the updated version:
That's happening because two requests reach
ShopifyCLI::Theme::DevServer:: Proxy
, but at this point, the first request goes in the first branch of this condition, and the second one goes to the second branch.The
replace_templates
is different for each request because@syncer.pending_updates
has an item for the first one, but it's empty for the second request.WHAT is this pull request doing?
This draft PR handles this is issue by keeping
params
@templates_to_replace
persistent. However, this solution is not great.@templates_to_replace
may get too large, which implies too large requests in the SFR.How to test your changes?
shopify-dev theme init my_theme
shopify-dev theme serve
layout/theme.liquid
filePost-release steps
None.
Update checklist