Skip to content

invoking suspense() with enabled: false will wait infinite while ssr #7609

@n0099

Description

@n0099

Describe the bug

const enabled = ref(false);
const { data, suspense } = useInfiniteQuery({ enabled })
await suspense()

Your minimal, reproducible example

https://codesandbox.io/p/devbox/eloquent-frog-3w6pk9?file=%2Fapp.vue

Steps to reproduce

  1. By default the preview will never end loading
  2. Change the line in /app.vue
-const enabled = ref(false);
+const enabled = ref(true);
  1. Refresh preview

Expected behavior

Instantly exit suspense() as there's nothing to fetch while ssr.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

nuxt^3.5.2
Windows 11
Chrome 126

Tanstack Query adapter

vue-query

TanStack Query version

5.45.0

TypeScript version

No response

Additional context

This only reproducible when using useInfiniteQuery(), useQuery() is not affected:

-const { data, suspense } = useInfiniteQuery({
+const { data, suspense } = useQuery({
  queryKey: ['test'],
  queryFn: fetcher,
-  initialPageParam: '',
-  getNextPageParam: () => '',
  enabled
})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions