Skip to content
Source
Sign inSign up
TanStack/query

fix(core): change `shouldFetchOptionally` condition #2556

Mergedjbee37142(GitHub profile, opens in a new tab)merged 3 commits intomaster fromrefs/pull/2556/headmerged by TkDodo View on GitHub

Showing 3 changed files with 132 additions and 0 deletions.

x
0 of 3 viewed, 3 left
1 addition and 0 deletionssrc/core/queryObserver.tsModified
View file
@@ -763,6 +763,7 @@
return (
options.enabled !== false &&
(query !== prevQuery || prevOptions.enabled === false) &&
+ (prevQuery.state.status !== 'error' || prevOptions.enabled === false) &&
isStale(query, options)
70 additions and 0 deletionssrc/react/tests/suspense.test.tsxModified
View file
@@ -577,4 +577,74 @@
expect(queryFn).toHaveBeenCalledTimes(1)
await waitFor(() => rendered.getByLabelText('fire'))
+​
+ it('should error catched in error boundary without infinite loop', async () => {
+ const key = queryKey()
+​
+ const consoleMock = mockConsoleError()
+​
+ let succeed = true
+​