From 523a1fad8f97db29a938c6720e8ff724ef3c447a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20G=C5=82owala?= Date: Tue, 18 Jun 2024 16:05:32 +0200 Subject: [PATCH] fix(nuxt): flag async data promise as cancelled only if defined (#27690) --- packages/nuxt/src/app/composables/asyncData.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/app/composables/asyncData.ts b/packages/nuxt/src/app/composables/asyncData.ts index 4808d4d6c8..c328f33864 100644 --- a/packages/nuxt/src/app/composables/asyncData.ts +++ b/packages/nuxt/src/app/composables/asyncData.ts @@ -543,7 +543,10 @@ function clearNuxtDataByKey (nuxtApp: NuxtApp, key: string): void { } if (key in nuxtApp._asyncDataPromises) { - (nuxtApp._asyncDataPromises[key] as any).cancelled = true + if (nuxtApp._asyncDataPromises[key]) { + (nuxtApp._asyncDataPromises[key] as any).cancelled = true + } + nuxtApp._asyncDataPromises[key] = undefined } }