Skip to content
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

Suspense does not include async components when hydrating #6638

Closed
danielroe opened this issue Sep 9, 2022 · 7 comments
Closed

Suspense does not include async components when hydrating #6638

danielroe opened this issue Sep 9, 2022 · 7 comments

Comments

@danielroe
Copy link
Member

Vue version

3.2.39

Link to minimal reproduction

https://stackblitz.com/edit/github-fktkzl-2bccdr

Steps to reproduce

  1. Load the app with npm run dev if it does not auto-start, looking at the browser console log.

  2. Press the 'Trigger suspense' button

What is expected?

I expect both in the initial hydration and in the subsequent suspense invocation for suspense not to have resolved by the time the async child component runs its setup.

What is actually happening?

In the initial hydration of the app, <Suspense> does not include child components within its cloak of suspense.

System Info

No response

Any additional comments?

No response

@mmis1000
Copy link
Contributor

It seems suspense only works with async setup instead of async component?

https://stackblitz.com/edit/github-fktkzl-bhp65u?file=src%2FApp.vue

If it changed to async setup, then everything works

@danielroe
Copy link
Member Author

Async components are wrapped into suspense when the suspense is triggered on client-side, and <Suspense> documentation says that async components should be treated as dependencies: https://vuejs.org/guide/built-ins/suspense.html#async-components.

@mmis1000
Copy link
Contributor

mmis1000 commented Sep 14, 2022

https://stackblitz.com/edit/github-fktkzl-ptamri?file=src%2FApp.vue

I think what breaks the source issue is nested suspense.
But that should probably be a separate issue.

The async component under nested suspense seems never be included by parent suspense in any case.
Which is how nuxt 3 use the Suspense here.

<NuxtRoot> Suspense
  <App> Async
    <Layout> Suspense <= Notice: they are nested
      <Page> Async

@danielroe
Copy link
Member Author

There is only one Suspense in the reproduction here.

And if you look at the PR I think you are referring to, you should see that we already ensure there is only one Suspense there.

@SebbeJohansson
Copy link

@danielroe in terms of getting this to work properly for nuxt3 has there been any progress? All issues point to this which has some merged PRs but it's still an issue.

@yyx990803
Copy link
Member

Closed via 1b8e197 (to be released in 3.5)

@kitroling
Copy link

kitroling commented Jul 24, 2024 via email

@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants