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

fix(nuxt): fix error on layout switching #21450

Merged
merged 14 commits into from
Jun 23, 2023
Merged

Conversation

antfu
Copy link
Member

@antfu antfu commented Jun 7, 2023

πŸ”— Linked issue

fix #13309
resolves #21544
resolves #21534

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

I am not 100% sure, but it fixes the error in this reproduction: #13309 (comment)

From what I see, is that our LayoutLoader is an async component that has a unique key. When the layout gets changed, a new LayoutLoader is created. Because Vue's suspense can not catch async patches on deep branches (an known issue), causing it to have a DOM that is already dismissed.

The solution to solve that is to wrap it with a suspensible Suspense to capture the update properly.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe
Copy link
Member

/trigger release

@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2023

πŸš€ Release triggered! You can now install nuxt@npm:nuxt3@pr-21450

@danielroe
Copy link
Member

I think we should inject <Suspense> above the layout loader here (ie. it's the right thing to do). We should also investigate the regressions in the test suite; they need to be solved, but I don't think it indicates this is the wrong approach.

@darthf1
Copy link

darthf1 commented Jun 21, 2023

Is it possible to land this the v3.6.0 as it resolves a lot of issues (at least for me)? @antfu mentioned this does not work with transitions enabled, but if it does not break anything its already an improvement? I have transitions disabled because #13471.

@danielroe
Copy link
Member

This is not merged because it does break some other things (not just transitions). But we'll merge ASAP as soon as we can, and release in a patch.

@darthf1
Copy link

darthf1 commented Jun 21, 2023

Ok thanks for replying!

@danielroe
Copy link
Member

/trigger release

@github-actions
Copy link
Contributor

πŸš€ Release triggered! You can now install nuxt@npm:nuxt3@pr-21450

@antfu antfu marked this pull request as ready for review June 22, 2023 19:32
@c-schwan
Copy link
Contributor

c-schwan commented Jun 22, 2023

@antfu is not ready for review, it does not fix all the linked issues ;-(

@danielroe
Copy link
Member

@c-schwan Could you be more specific? A partial fix is still worth merging but sometimes error messages like #13309 stem from different causes and aren't fixed in a single change.

@c-schwan
Copy link
Contributor

c-schwan commented Jun 22, 2023

@c-schwan Could you be more specific? A partial fix is still worth merging but sometimes error messages like #13309 stem from different causes and aren't fixed in a single change.

#21701 should work on my opinion for major releases. if you having a guard middleware like auth protecting page resources it should work as expected, or am i wrong?

@danielroe
Copy link
Member

@c-schwan This PR fixes that issue, in my testing.

@c-schwan
Copy link
Contributor

@c-schwan This PR fixes that issue, in my testing.

Nuxt 3.6.0-28124217.43844474 (npm:nuxt3@pr-21450)

https://stackblitz.com/edit/middleware-nuxt

but still not working

@danielroe
Copy link
Member

Have you tried it locally?

@c-schwan
Copy link
Contributor

c-schwan commented Jun 22, 2023

Have you tried it locally?

i tried locally with the stackblitz project and locally in our project, both no luck

@c-schwan
Copy link
Contributor

Have you tried it locally?

it works well on the first time switching the layout but going back (Browser or via NuxtLink) it won't be called anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants