-
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
[feat]: Converge behaviour between develop and build #10706
Comments
I love this idea! Yeah, this would help people a ton in catching weird React SSR issues early. This is tied too to issues like #8342 Something a lot of people try to do is run Lighthouse on their dev server and complain Gatsby is super slow and has huge JS files. |
great summary of issues with same root! I agree totally on SSR during develop. But not generating all pages. CLI should also educate more about But generating every of 20.000 pages, every time I change I save the CSS file will hurt badly the dev hot-reload experience. |
@dcorb My initial idea is to lazy generate only the page that user visit which would match the behaviour of production builds where html is only really used for initial paint (further navigation is done entirely client-side with react) |
@pieh has sense 💯 |
@pieh that does sound like a really, really nice approach, one that could lead to a decrease on issues regarding a particular subset. |
Another issue relating to this at #10749 |
One caveat of only rendering the entry point during
for the entry point. For example:
Everything will work fine without warnings. The moment the user refreshes the page at Rendering everything during |
We could also queue pages to render in the background. Rendering other pages isn't on the critical path. We also would only need to render one page per component. We could track file changes and re-SSR them. |
Rendering only one instance of a page or template makes sense. Queuing pages to render in the background could lead to strange behaviour where develop initially succeeds and then fails asynchronously (while the user has already switched over to the browser) We could only warn (and not panic) on issues but I think we ought to try to keep behaviour as close to build as possible and therefore panic |
Another issue that could be potentially handled by this is #9911 |
Is there a docs page related to this topic? Some tips/advice/best practices about it would be a good reference to have. My linked issue #11099 uses URL params to affect a component, one prop adds blur if true, another adds a div if true, the latter works but the prop that would update/modify styles doesn't. I know that original issue comment here quotes about why that behaviour happens with how React works, but I think navigating to other internal pages of the site being client-side app will not run into the issue, so navigating back to that same page would then render correctly? So why doesn't the page re-render itself upon hydration which should fix all this? It'd be run once, so shouldn't be all that expensive and would resolve many of the problems? |
Not at the moment, unfortunately. I definitely see value in adding some documentation for hydration gotchas (since a lot of people have been hitting them lately).
Seems counterintuitive to me because (if I understand this correctly) it defeats the purpose of any SSR |
I guess this issue serves to collect those? It's a bit confusing as a new user to gatsby with it blurring the lines between static and dynamic sites. In my case I know gatsbygram was using the URL location prop to be a bit dynamic like and use that information to render components/page in certain ways, so I thought I could do similar and it worked in develop, then confused for some time trying to pin down what was going wrong with the production build.
Isn't the SSR part what we get prior to hydration? Not sure what difference it makes at the hydration point beyond ensuring the page is "patched" up to reflect what it would when navigated to from any other page vs loaded directly via url? |
I might've misunderstood what you meant by this. When you say re-render itself upon hydration, do you mean discarding everything in the DOM and React rendering on a clean slate? This can be jarring after the initial HTML render. |
Yes, anything on the page that was related to React, assuming that'd fix all the issues.
Oh that's not good then :( |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! Thanks for being a part of the Gatsby community! 💪💜 |
This would be a great improvement, but this issue doesn't feel very actionable right now. Is there a more focussed issue we can link to? |
@m-allanson I just filed #19563. It documents a case where It includes a minimal reproduction that clearly demonstrates this problem: |
Have you considered running SSR on the client in DEV to simulate a subset of these problems without taking a perf hit? |
Possibly related: #22287 |
Just chiming in in support of this issue. Production-only issues have been a persistent headache on a complex site I'm building/maintaining (stellar/new-docs, particularly the API Reference content), and things like initial load optimizations have been quite tricky to test because of the lack of initial HTML served when requesting a page in dev mode. Add in the various caches and we've had a number of bugs squeak out because it's difficult to confirm behavior precisely. |
Going to close this in favor of #25729 |
A common theme amongst several issues (#10689, #10370) over some time now has been
Common Scenarios
html
in develop and people often see issues when theybuild
becauseI think we need to converge the differences in behaviour between develop and build as much as possible (without breaking our great hot reloading experience) so that
build
will succeed without unexpected issues ifdevelop
was working fineOne action point that @pieh and I found from this is
Please post more and your thoughts about this
The text was updated successfully, but these errors were encountered: