fix(nuxt): defer shared asyncData promises to next tick (#27329)

This commit is contained in:
Daniel Roe 2024-05-23 17:40:23 +01:00 committed by GitHub
parent 5f60aa5a48
commit 0e90e87ef7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -229,7 +229,7 @@ export function useAsyncData<
const value = nuxtApp.ssrContext!._sharedPrerenderCache!.get(key)
if (value) { return value as Promise<ResT> }
const promise = nuxtApp.runWithContext(_handler)
const promise = Promise.resolve().then(() => nuxtApp.runWithContext(_handler))
nuxtApp.ssrContext!._sharedPrerenderCache!.set(key, promise)
return promise

View File

@ -393,7 +393,11 @@ export default defineUntypedSchema({
* })
* ```
*/
sharedPrerenderData: false,
sharedPrerenderData: {
async $resolve (val, get) {
return val ?? ((await get('future') as Record<string, unknown>).compatibilityVersion === 4)
},
},
/**
* Enables CookieStore support to listen for cookie updates (if supported by the browser) and refresh `useCookie` ref values.