diff --git a/packages/nuxt/src/app/composables/asyncData.ts b/packages/nuxt/src/app/composables/asyncData.ts index 92e62b32f7..aafb729e14 100644 --- a/packages/nuxt/src/app/composables/asyncData.ts +++ b/packages/nuxt/src/app/composables/asyncData.ts @@ -229,7 +229,7 @@ export function useAsyncData< const value = nuxtApp.ssrContext!._sharedPrerenderCache!.get(key) if (value) { return value as Promise } - const promise = nuxtApp.runWithContext(_handler) + const promise = Promise.resolve().then(() => nuxtApp.runWithContext(_handler)) nuxtApp.ssrContext!._sharedPrerenderCache!.set(key, promise) return promise diff --git a/packages/schema/src/config/experimental.ts b/packages/schema/src/config/experimental.ts index 8d01cf72a4..b90a378ac3 100644 --- a/packages/schema/src/config/experimental.ts +++ b/packages/schema/src/config/experimental.ts @@ -393,7 +393,11 @@ export default defineUntypedSchema({ * }) * ``` */ - sharedPrerenderData: false, + sharedPrerenderData: { + async $resolve (val, get) { + return val ?? ((await get('future') as Record).compatibilityVersion === 4) + }, + }, /** * Enables CookieStore support to listen for cookie updates (if supported by the browser) and refresh `useCookie` ref values.