mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxt): stop tracking suspense when error hydrating page (#25389)
This commit is contained in:
parent
48ce560901
commit
7e375b5ed8
@ -5,7 +5,7 @@ import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
||||
// eslint-disable-next-line import/no-restricted-paths
|
||||
import type { PageMeta } from '../../pages/runtime/composables'
|
||||
|
||||
import { useRoute } from '../composables/router'
|
||||
import { useRoute, useRouter } from '../composables/router'
|
||||
import { useNuxtApp } from '../nuxt'
|
||||
import { _wrapIf } from './utils'
|
||||
import { LayoutMetaSymbol, PageRouteSymbol } from './injections'
|
||||
@ -71,6 +71,10 @@ export default defineComponent({
|
||||
context.expose({ layoutRef })
|
||||
|
||||
const done = nuxtApp.deferHydration()
|
||||
if (import.meta.client && nuxtApp.isHydrating) {
|
||||
const removeErrorHook = nuxtApp.hooks.hookOnce('app:error', done)
|
||||
useRouter().beforeEach(removeErrorHook)
|
||||
}
|
||||
|
||||
if (import.meta.dev) {
|
||||
nuxtApp._isNuxtLayoutUsed = true
|
||||
@ -97,7 +101,7 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
}) as unknown as DefineComponent<{
|
||||
name?: (unknown extends PageMeta['layout'] ? MaybeRef<string | false> : PageMeta['layout']) | undefined;
|
||||
name?: (unknown extends PageMeta['layout'] ? MaybeRef<string | false> : PageMeta['layout']) | undefined
|
||||
}>
|
||||
|
||||
const LayoutProvider = defineComponent({
|
||||
|
@ -20,7 +20,7 @@
|
||||
import { defineAsyncComponent, onErrorCaptured, onServerPrefetch, provide } from 'vue'
|
||||
import { useNuxtApp } from '../nuxt'
|
||||
import { isNuxtError, showError, useError } from '../composables/error'
|
||||
import { useRoute } from '../composables/router'
|
||||
import { useRoute, useRouter } from '../composables/router'
|
||||
import { PageRouteSymbol } from '../components/injections'
|
||||
import AppComponent from '#build/app-component.mjs'
|
||||
import ErrorComponent from '#build/error-component.mjs'
|
||||
@ -31,6 +31,10 @@ const IslandRenderer = import.meta.server
|
||||
|
||||
const nuxtApp = useNuxtApp()
|
||||
const onResolve = nuxtApp.deferHydration()
|
||||
if (import.meta.client && nuxtApp.isHydrating) {
|
||||
const removeErrorHook = nuxtApp.hooks.hookOnce('app:error', onResolve)
|
||||
useRouter().beforeEach(removeErrorHook)
|
||||
}
|
||||
|
||||
const url = import.meta.server ? nuxtApp.ssrContext.url : window.location.pathname
|
||||
const SingleRenderer = import.meta.test && import.meta.dev && import.meta.server && url.startsWith('/__nuxt_component_test__/') && defineAsyncComponent(() => import('#build/test-component-wrapper.mjs')
|
||||
|
@ -9,6 +9,7 @@ import type { RouterViewSlotProps } from './utils'
|
||||
import { generateRouteKey, wrapInKeepAlive } from './utils'
|
||||
import { RouteProvider } from '#app/components/route-provider'
|
||||
import { useNuxtApp } from '#app/nuxt'
|
||||
import { useRouter } from '#app/composables/router'
|
||||
import { _wrapIf } from '#app/components/utils'
|
||||
import { LayoutMetaSymbol, PageRouteSymbol } from '#app/components/injections'
|
||||
// @ts-expect-error virtual file
|
||||
@ -49,6 +50,10 @@ export default defineComponent({
|
||||
let vnode: VNode
|
||||
|
||||
const done = nuxtApp.deferHydration()
|
||||
if (import.meta.client && nuxtApp.isHydrating) {
|
||||
const removeErrorHook = nuxtApp.hooks.hookOnce('app:error', done)
|
||||
useRouter().beforeEach(removeErrorHook)
|
||||
}
|
||||
|
||||
if (props.pageKey) {
|
||||
watch(() => props.pageKey, (next, prev) => {
|
||||
@ -158,5 +163,5 @@ function hasChildrenRoutes (fork: RouteLocationNormalizedLoaded | null, newRoute
|
||||
if (!fork) { return false }
|
||||
|
||||
const index = newRoute.matched.findIndex(m => m.components?.default === Component?.type)
|
||||
return index < newRoute.matched.length -1
|
||||
return index < newRoute.matched.length - 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user