Skip to content
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

Maximum update depth exceeded #8677

Open
yWilliamLima opened this issue Feb 19, 2025 · 8 comments
Open

Maximum update depth exceeded #8677

yWilliamLima opened this issue Feb 19, 2025 · 8 comments

Comments

@yWilliamLima
Copy link

yWilliamLima commented Feb 19, 2025

Describe the bug

I am getting the error "Maximum update depth exceeded"

Your minimal, reproducible example

https://stackblitz.com/~/github.com/yWilliamLima/test-error

Steps to reproduce

It usually occurs after a while of running whenever changing pages/routes

Expected behavior

Do not return this error

How often does this bug happen?

Sometimes

Screenshots or Videos

Image
Image

Platform

OS: Windows 11
Browser: Chrome
Node: 22.12.0

Tanstack Query adapter

None

TanStack Query version

5.66.5

TypeScript version

5.7.3

Additional context

The error in the console does not occur locally, only in stackblitz
Maybe because of this error in the stackblitz console it doesn't happen, because it gives a refresh
Because it is a minimal example, it takes a while to occur, but in my project it occurs frequently

@tariqkb
Copy link

tariqkb commented Feb 19, 2025

I started getting this error after upgrading as well. I narrowed it down to version v5.66.4 introducing this behavior.

@yWilliamLima
Copy link
Author

I started getting this error after upgrading as well. I narrowed it down to version v5.66.4 introducing this behavior.

Your test is very good, the problem was actually introduced in v5.66.4, I downgraded to v5.66.3 and the problem does not occur

@TkDodo
Copy link
Collaborator

TkDodo commented Feb 19, 2025

@juliusmarminge 5.66.4 was our hydration changes 😕

@joseph0926
Copy link
Contributor

I think the following part of the logic added by #8383 in the PR might be causing some problems.

https://github.com/TanStack/query/pull/8383/files#diff-771e81c633f399ddff578509c1355021bff3ce55afb12d281cb9bc110842665fR83-R86

This is because the code in the above link thinks that the new logic is new if the “promise.status” is different.

But https://github.com/TanStack/query/pull/8383/files#diff-da66ebb93eacffd07c6ea6e697db57d6091050af95da336ea10e1aaedb07ef7cR86 is chasing a “promise”, so I think a new “promise” will be created each time.
(or is the “promise.status” actually different each time?)

Wouldn't that cause “Maximum update depth exceeded” to be thrown because the new code thinks it's new every time?

@juliusmarminge
Copy link
Collaborator

can anyone provide a minimal repro? I can look into this tonight but would help to have something simple to debug

@yWilliamLima
Copy link
Author

yWilliamLima commented Feb 21, 2025

I did some validations in my personal project where the error occurs frequently, where if I export the Page as async and use await in prefetchQuery the problem does not occur:

export default async function Page() {
  const queryClient = getQueryClient()

  await queryClient.prefetchQuery({ ...getApiV1ActivitiesOptions() })

@juliusmarminge
Copy link
Collaborator

yea but then you're no longer sending promises down so you're hitting completely different code paths with that - not really comparable

@juliusmarminge
Copy link
Collaborator

I just want a state where it's failing on that PR I linked 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants