-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next js 15 with dynamicIO: true returned server error #8277
Comments
Not sure if I discussed this with you, but it came up on Discord as well. The reason is likely that we initiate our mutationIds with
It doesn’t have to be If you have an idea what that could be, please file a PR. |
Actually, we only serialize the query/packages/query-core/src/mutationCache.ts Lines 205 to 207 in 24f1d45
So we can also initialize mutations with |
(edit) DISCLAIMER: THIS DOESN'T WORK !!Honestly, I can't think of any way to consistently generate unique strings for older browsers. Currently, I tried to use
|
I'm writing this as a note for future developers. I ended up patching |
Apologies for commenting on a closed issue, but do we have a final (and official) verdict on what to do to be able to use TanStack Query with Next.js 15 Canary? I understand that it is an experimental build and so the package maintainers should not spend their time and effort to support something that is not finalized and stable, but if there is any way to utilize TanStack Query with the dynamicIO and PPR features and test it to be ready for an upgrade once they land in main, I would love to learn how. |
Perhaps |
Didn’t know about |
Absolutely! I just created the PR that fixes this. |
Before the patch is released, adding a Suspense boundary w/ null fallback directly above your Providers works. |
I implemented a temporary fix for this issue until ali-idrizi PR is merged using the code below import { MutationCache } from '@tanstack/react-query';
export class MutationCache_TEMP_FIX extends MutationCache {
constructor() {
const old = Date.now;
Date.now = () => Math.round(performance.timeOrigin + performance.now());
super();
Date.now = old;
}
} Then, I applied the new implementation as follows: return new QueryClient({
mutationCache: new MutationCache_TEMP_FIX(),
defaultOptions: {
...
},
}); I know this solution isn't ideal, but it works as a stopgap measure while waiting for the official fix. Disclaimer: I haven’t tested this solution thoroughly, but it did get my build working for now. |
Hey folks, I implemented The fix to make this use timeOrigin might work today but because it is so tempting to use this value for non-telemetry purposes we may end up having to treat it similar to Date.now() in that it must be excluded from prerenders unless explicitly cached so I don't think this approach is going to solve the compatability issue. You've already discovered you can do things like I put together a PR to potentially address the compatibility within MutationCache itself here: #8450 I'm not familiar with all the constraints that might be in play so it's possible my proposal isn't suitable for some reason but at the moment I think it is, so when the project maintainers have a chance to review we can hopefully land this and unblock this usage with the |
Describe the bug
Running the "React Example: Nextjs App Prefetching" from the docs with
dynamicIO: true
setting on next.config.ts return this error shown below. The code is available here.Your minimal, reproducible example
https://github.com/yudistiraashadi/next15-tanstack-query-canary
Steps to reproduce
npx create-next-app@canary
pnpm add @tanstack/react-query
andpnpm add -D @tanstack/react-query-devtools
pnpm run dev
and open localhost:3000Expected behavior
No error
How often does this bug happen?
Every time
Screenshots or Videos
Screencast.from.11-11-24.15.53.38.webm
Platform
Tanstack Query adapter
None
TanStack Query version
5.59.20
TypeScript version
5.6.3
Additional context
No response
The text was updated successfully, but these errors were encountered: