-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
fix(gatsby): fix infinite reloads when resources fail #10141
Conversation
I'm not sure about using innerHTML - it will work for initial mount, but afterwards it would prevent page transitions if resources for next page failed to load? (as html markup hold in state is from first page). I'm thinking if we shouldn't just fail there (i.e. throw error) |
If we're online this won't happen, because upon the first failure we immediately reload the page - upon second failure (i.e. after reloading) we've already loaded the full HTML for the page which failed, so rendering static HTML will work correctly. However, if we go offline then later come back online and try to visit that page, this could happen (since the flag will still be set) - so I agree with you it might be better to just throw an error. I'll do some more testing later and try out these different scenarios. |
@pieh I did some testing and I think the current approach works best - if we throw an error (instead of returning static HTML), links stop working, because we've thrown an error internally, whereas returning static content doesn't cause this problem. Also, re: the "offline then revisit" scenario which I thought might be a problem - it actually works fine, because we remove the flag on any subsequent page load (not necessarily just the same page). |
I'll pull this and do some local testing and hopefully merge soon |
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.
🙏 Thanks @davidbailey00!
- Check if resources fail (as before) - Upon any failure, render static HTML instead of dynamically rendering the children - Upon initial failure, reload the page and mark the path as failed - Upon second failure, don't reload the page and unflag it (since it might have just been a temporary failure and we want it to retry the next time) Fixes gatsbyjs#10074
to pull changes added in gatsbyjs#10141
Fixes #10074