-
Hi everyone, I'm running into a frustrating issue where my Next.js app (version 15.4.4) suddenly started failing to build static pages due to prefetchQuery calls. This wasn’t happening before — it used to work perfectly. ❌ Build error
It seems like the issue is related to query prefetching taking too long. Here's an example of a page where I prefetch some data:
Here’s my TanStack Query version: "@tanstack/react-query": "^5.83.0", And my QueryClientProvider setup:
✅ What worked before 🔍 What I’ve tried Increasing build timeout (doesn't help). Ensuring getPetimType and other logic isn't blocking or throwing. Any ideas what could have changed or what I should do to make this work again? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
have you narrowed down which of the 3 prefetches are taking too long? also you should probably re-use your - const queryClient = new QueryClient();
+ const queryClient = makeQueryClient(); |
Beta Was this translation helpful? Give feedback.
makeQueryClient
, if taken from the docs, is meant to work in both environments. You even have theisServer
check in your code, so it should just create a new QueryClient every time, just with the same options. Unless you maybe need different options?I just saw that you are prefetching for the same queryKey in parallel. Is that on purpose? I think what you want is:
…