-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Root level suspension doesn't work as expected #3661
Comments
I haven't taken a look yet but if you wrap the children of your |
@JoviDeCroock However, it fixed some initial layout shift issue I chose not to mention here (you can see that by refreshing the deployed Preact version of the app with cache disabled). So thanks for the tip! |
Oh, expected that to tackle both issues 😅 yes our Suspense implementation has some flaws at this moment in time especially with how it handles shifting the layout in and out. First attempt at reproducing minimally https://codesandbox.io/s/practical-field-txgllk?file=/src/index.js |
One of your deps might be behaving weirdly in prod mode because I can't reproduce this in dev - checked out your repo and everything, it just works Will need a minimal way to reproduce but generally would try with an empty div as fallback and see the results like that as it can give us a clue |
@JoviDeCroock I tried replacing the The new deploy (with the Edit: it seems that I've been missing on some parts - even before replacing the
Would you like me to open a separate issue for |
I can reproduce the last thing you said i.e. a navigation resulting in some loop but the current one is not happening for me 😅 the navigation one doesn't seem caused by 10.10.2 in others the navigation just isn't working for i.e. 10.10.1 doing a hot fix there to not use Screen.Recording.2022-08-11.at.08.36.19.movFor the latter navigational bug it seems related to EDIT: it looks like #3655 has an effect on the |
@JoviDeCroock Thanks for trying to resolve these issues :) |
Oh you mean that when an error is thrown you prefer the UI not rendering in general? |
@JoviDeCroock https://github.com/theninthsky/client-side-rendering#preventing-sequenced-rendering |
Well just for clarity, it doesn't have much to do with showing the app in one draw at the moment as it will never show the part you are illustrating as your body as that is throwing an error. This is the resilience part of your application, recovering from errors, I would agree that maybe showing nothing when nothing is coming in the future is preferable but that would go paired with for instance using a loading fallback on a We have done prior work on the whole swapping thing that I guess is illustrated under "sequenced" rendering, browsing around on wmr shows an early implementation of that where the boundary keeps around the prior page as a fallback while rendering the full new view when it comes in. I deviate, I guess what we can do is destroy the UI when errors get thrown but yes error-boundaries are your friend there. Where we differ from React here is that we keep our VDOM and DOM around when a suspense boundary triggers because we don't want to reconstruct everything. |
@JoviDeCroock The only reason I block the url of the async pages is to demonstrate that that suspension doesn't work properly. However, I agree that suspending the entire app is not that important, since everything loads so fast that users will rarely see a "sequenced render". Its initial intention was to make FCP and LCP equal. |
Saying this in the politest way possible, we are still talking about different things. I am saying that the suspension does work correctly try with const wait = ms => new Promise(res => setTimeout(() => {
res()
}, ms))
const Home = lazyPrefetch(async () => {
await wait(2500)
return import(/* webpackChunkName: "index" */ 'pages/Home')
}) Which will exhibit the aforementioned behavior correctly, as shown in the video. The difference is that if you block a request the JS-Runtime for |
@JoviDeCroock So in fact Preact's Suspense does work properly :) I will close this issue now, would you like me to open an issue for the infinite loop when navigating? |
Feel free to open an issue, I have narrowed it down to zustand and the |
Preact version:
10.10.2
.Bug Description
When wrapping the entire
<App>
with Suspense, we can see some odd behavior.It seems that only lazy chunks are suspended, instead of the entire app.
To Reproduce
Open the React version of the app: https://client-side-rendering.pages.dev
Open the Preact version of the app: https://8009dc66.client-side-rendering.pages.dev
In the network tab, block the
index.[hash].js
request URL for each page and reload (this blocked file is the Home page chunk).The React app will look like this:
While the Preact app will look like this:
As we can see, the navigation bar does not suspend, since its not lazily loaded.
Source can be found here: https://github.com/theninthsky/client-side-rendering
There's a main (React) branch and a preact branch. Both are completely identical, except for the Preact configurations in
webpack.config.js
andtsconfig.json
.Expected behavior
The entire app should suspend until its lazy chucks are loaded.
Sorry to bother you again, but this is the final step towards completely replacing React with Preact.
The text was updated successfully, but these errors were encountered: