File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ export function useBaseQuery<
149149 return state . refetch ( ...args )
150150 }
151151
152- let isSuspenseFetching = false
152+ let suspenseFetchCount = 0
153153
154154 const suspense = ( ) => {
155155 return new Promise < QueryObserverResult < TData , TError > > (
@@ -166,14 +166,14 @@ export function useBaseQuery<
166166 )
167167 if ( optimisticResult . isStale ) {
168168 stopWatch ( )
169- isSuspenseFetching = true
169+ suspenseFetchCount += 1
170170 observer . fetchOptimistic ( defaultedOptions . value ) . then (
171171 ( result ) => {
172- isSuspenseFetching = false
172+ suspenseFetchCount -= 1
173173 resolve ( result )
174174 } ,
175175 ( error : TError ) => {
176- isSuspenseFetching = false
176+ suspenseFetchCount -= 1
177177 if (
178178 shouldThrowError ( defaultedOptions . value . throwOnError , [
179179 error ,
@@ -210,7 +210,7 @@ export function useBaseQuery<
210210 [ error as TError , observer . getCurrentQuery ( ) ] ,
211211 )
212212
213- if ( shouldThrow && ! isSuspenseFetching ) {
213+ if ( shouldThrow && suspenseFetchCount === 0 ) {
214214 throw error
215215 }
216216 }
You can’t perform that action at this time.
0 commit comments