Skip to content

useAsyncQuery ignores server: false option and executes during SSR #661

Description

@omnichronous

Environment

  • Operating System: Linux
  • Node Version: v22.11.0
  • Nuxt Version: 3.15.4
  • CLI Version: 3.22.5
  • Nitro Version: 2.11.5
  • Package Manager: npm@10.9.0
  • Builder: -
  • User Config: $development, $production, compatibilityDate, app, logLevel, srcDir, devServer, devtools, sourcemap, modules, auth, unleash, analytics, css, eslint, stylelint, nitro, googleFonts, imports, pinia, lodash, fetch, jsonapi, apollo, runtimeConfig, vite, tailwindcss, primevue, svgo, typescript, proxy, sentry
  • Runtime Modules: nuxt-svgo@4.0.8, @nuxtjs/eslint-module@4.1.0, @nuxtjs/stylelint-module@5.2.1, @nuxtjs/tailwindcss@6.12.2, @nuxtjs/google-fonts@3.2.0, @pinia/nuxt@0.4.11, nuxt-lodash@2.5.3, @primevue/nuxt-module@4.2.4, ~/modules/fetch, @shared/nuxt-jsonapi@0.0.6, ~/modules/auth, @shared/nuxt-unleash@0.0.5, @shared/nuxt-analytics@0.0.3, @vee-validate/nuxt@4.15.0, @nuxt/scripts@0.10.5, @nuxt-alt/proxy@2.5.8, @sentry/nuxt/module@9.5.0, @nuxtjs/apollo@5.0.0-alpha.15
  • Build Modules: -

Describe the bug

When passing server: false to useAsyncQuery (internally to useAsyncData), the Apollo client query still executes on server-side (SSR).

Looking at composables.ts, the fn doesn't check import.meta.server, which causes this option to be ignored.

Expected behaviour

Setting server: false should skip the query execution during SSR and only run it on client-side.

Reproduction

// Example composable usage
const { result } = useAsyncQuery({
  query: MY_QUERY,
  variables: {},
  server: false
})

This triggers a request during SSR. It should not.

Additional context

Related issues:

Logs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions