content icon indicating copy to clipboard operation
content copied to clipboard

Second call `queryContent` in `useAsyncData` never resolve

Open cawa-93 opened this issue 3 years ago • 5 comments

Environment

Reproduction

  1. https://stackblitz.com/edit/github-6ahpka?file=app.vue
  2. https://stackblitz.com/edit/github-6ahpka-h93acz?file=app.vue

Describe the bug

In my example, tags are first quered, then posts by tag name. The second calls queryContent to find posts stuck and never resolves. If you change the order of calls, the posts will be loaded and the tags will "stuck"

Additional context

No response

Logs

No response

cawa-93 avatar Aug 23 '22 12:08 cawa-93

This is an upstream framework issue. You can follow https://github.com/nuxt/nuxt.js/issues/14614.

danielroe avatar Aug 23 '22 14:08 danielroe

Still relevant for nuxt rc9 and content 2.1.0

You should see { tags } and { posts } in logs: https://stackblitz.com/edit/github-6ahpka?file=app.vue But there are only { tags }

cawa-93 avatar Sep 08 '22 14:09 cawa-93

Looks like we can wrap both queries with Promise.all([query1, query2]). With this it worked for me.

luxterful avatar Sep 11 '22 11:09 luxterful

Looks like we can wrap both queries with Promise.all([query1, query2]). With this it worked for me.

It's will not work if second queri depend first

cawa-93 avatar Sep 11 '22 11:09 cawa-93

It seems related only for SSR. My changed demo: https://stackblitz.com/edit/github-6ahpka-h93acz?file=app.vue

On SSR query will throw error:

Error: nuxt instance unavailable
    at useNuxtApp (/home/projects/github-6ahpka-h93acz/node_modules/nuxt/dist/app/nuxt.mjs:142:13)
    at useRuntimeConfig (/home/projects/github-6ahpka-h93acz/node_modules/nuxt/dist/app/nuxt.mjs:150:10)
    at withContentBase@/home/projects/github-6ahpka-h93acz/node_modules/ (nuxt/content/dist/runtime/composables/utils.mjs:7:102)
    at createQueryFetch/<@/home/projects/github-6ahpka-h93acz/node_modules/ (nuxt/content/dist/runtime/composables/query.mjs:25:41)
    at find@/home/projects/github-6ahpka-h93acz/node_modules/ (nuxt/content/dist/runtime/query/query.mjs:27:24)
    at <anonymous> (/home/projects/github-6ahpka-h93acz/app.vue:30:10)
    at <anonymous> (<anonymous>)

But if you refresh data in client-side it will load successful

cawa-93 avatar Sep 11 '22 11:09 cawa-93

Maybe this helps: https://github.com/nuxt/content/issues/1368

kirtan403 avatar Nov 10 '22 11:11 kirtan403