alt-tabbing back fires 63 xhr requests on tanstack query v5, where do i look TanStack Query
Dashboard, TanStack Query v5.62, six panels mounted at once in a tab layout. Every time I switch to another window and come back, the network panel shows 63 XHR requests inside about 1.4 seconds. A good chunk of them are the same endpoint with the same querystring.
Devtools shows 21 cache entries whose first key element is 'todos', and they all print identically in the list, which is the part I do not understand - if they print the same, why are they separate entries?
Key and cache listing attached. Setting refetchOnWindowFocus: false globally makes the burst disappear, but that feels like taping over the warning light.
@torque_spec · 3h ago · 2 replies
For the 21 entries, stop reading the devtools list - it truncates nested objects, so
filters:{...}will look identical for keys that are nothing alike. Dump the hashes instead:Diff two of those strings and the culprit falls out immediately. Nine times out of ten it is a
Datesomewhere in the filter object being rebuilt on render, because it serialises down to the millisecond.Reply
Report
@sdcard_sid · 3h ago
It is exactly that.
updatedAfter: subDays(new Date(), 7).toISOString()sitting in the filters object, so every parent render produced a key that differed in the milliseconds field. Rounded it to the day and the entry count went from 21 to 3.Reply
Report