From 3161c1545eb2835dc7c9a12c83bc292ca6f36172 Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Fri, 23 Aug 2024 00:16:33 +0200 Subject: [PATCH] fix: move back into Promise.resolve --- packages/nuxt/src/app/composables/component.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/nuxt/src/app/composables/component.ts b/packages/nuxt/src/app/composables/component.ts index c0eb7a5d6d..d6b2773ee2 100644 --- a/packages/nuxt/src/app/composables/component.ts +++ b/packages/nuxt/src/app/composables/component.ts @@ -47,8 +47,7 @@ export const defineNuxtComponent: typeof defineComponent = _fetchKeyBase: key, ...options, setup (props, ctx) { - const res = setup ? setup(props, ctx) : {} - const result = Promise.resolve(res).then(() => res || {}) + const res = setup ? Promise.resolve(setup(props, ctx)).then(r => r || {}) : {} const promises: Promise[] = [] if (options.asyncData) { promises.push(runLegacyAsyncData(res, options.asyncData)) @@ -59,9 +58,9 @@ export const defineNuxtComponent: typeof defineComponent = useHead(typeof options.head === 'function' ? () => options.head(nuxtApp) : options.head) } - return Promise.resolve(result) + return Promise.resolve(res) .then(() => Promise.all(promises)) - .then(() => result) + .then(() => res) .finally(() => { promises.length = 0 })