question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Root level suspension doesn't work as expected

See original GitHub issue

Preact version: 10.10.2.

Bug Description

When wrapping the entire <App> with Suspense, we can see some odd behavior.

createRoot(document.getElementById('root')).render(
  <BrowserRouter>
    <Suspense>
        <App />
    </Suspense>
  </BrowserRouter>
)

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:

image

While the Preact app will look like this:

image

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 and tsconfig.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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
JoviDeCroockcommented, Aug 11, 2022

Feel free to open an issue, I have narrowed it down to zustand and the useSyncExternalStore of Preact not fully working with the selector usage of zustand https://codesandbox.io/s/great-microservice-i9p35o?file=/src/index.js @theninthsky

1reaction
JoviDeCroockcommented, Aug 11, 2022

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 import will throw an Error. Errors aren’t handled by Suspense in our case as the behavior here slightly deviates from the default one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

School Suspensions Do More Harm than Good | NEA
New study finds more severe suspensions have greater negative effects on learning outcomes, attendance, and future behavior; educators have ...
Read more >
In-school suspensions the answer to school discipline? Not ...
At some schools, behavior counseling is a key part of in-school suspension programs. Do you count on EdSource's education coverage?
Read more >
Air suspension Leveling problem after UPPER CONTROL ...
After installing them, we did calibration using VAG COM. Everything is back to order and working as normal. Suspension is sitting leveled. We ......
Read more >
Addressing the Root Causes of Disparities in School Discipline
Addressing the Root Cause of Disparities in School Discipline: An Educator's Action Planning Guide provides a three-stage method to accomplish this task.
Read more >
In-School Suspension: 6 Key Elements You Need To Consider
Benefits of in-school suspension programs ; Solve root problems; Encourage positive behavior; Discourage repeat offenders ; Academic support; Time ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found