query icon indicating copy to clipboard operation
query copied to clipboard

Maximum update depth exceeded

Open yWilliamLima opened this issue 1 year ago • 27 comments

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

yWilliamLima avatar Feb 19 '25 17:02 yWilliamLima

+1

cgaravitoq avatar Mar 28 '25 11:03 cgaravitoq

@AntonioErdeljac

The error occurs when I try get the data from the new pages GetAllProducts(page=1, size=10). Before it, the RQ works well.

I tried downgrading the RQ version. But it didn't work. I used fetch data to put it in a Shadcn table. I guess RQ and Shadcn aren't a good match. I don't know why yet, but the error is in the Shadcn table

Image

Image

The logger said that the error occurs in this line: {table.getRowModel().rows?.length ? ( Image

if i find out something I back here.

Merus23 avatar Apr 14 '25 01:04 Merus23

@Merus23 What you're seeing is probably an unrelated error. Look into how your table component's parent is rendered, how table is getting data and whether the data is referentially stable.

zorzysty avatar Apr 14 '25 06:04 zorzysty

I am experiencing this error with RQ version 5.66.9 and tRPC 11 after throwing error in TRPC procedure ( given that the procedure is being prefetched in server component ) I am following the basic setup described here: https://trpc.io/docs/client/tanstack-react-query/server-components#leveraging-suspense

elliason avatar Apr 15 '25 12:04 elliason

I don't know much about under the hood, but I get this seemingly if I have a prefetched query that never gets consumed.

In the below example, it works totally fine, however if I comment out <PokemonInfo /> then I start getting the exceeded error.

export default function Home() {
  const queryClient = getQueryClient();

  void queryClient.prefetchQuery(pokemonOptions);

  return (
    <HydrationBoundary state={dehydrate(queryClient)}>
      <PokemonInfo />
    </HydrationBoundary>
  );
}

AleskiWeb avatar May 14 '25 17:05 AleskiWeb

I have a fix up in #9157, if you want to help verify it works for you, you can install the prerelease packages with:

npm i https://pkg.pr.new/@tanstack/query-core@1568117
npm i https://pkg.pr.new/@tanstack/react-query@1568117

(You can verify those are the packages from the PR and find any new ones in case the PR updates by going to the Checks and clicking pkg.pr.new)

Ephem avatar May 19 '25 20:05 Ephem

I thought my PR would solve this, and I'm pretty sure it solves some versions of it, but I've seen this pop up again even after the PR, so reopening to investigate.

Ephem avatar May 22 '25 17:05 Ephem