Skip to content

Commit 1a28687

Browse files
committed
Use better check for "forced query" in queryThunk condition check
1 parent ce98d69 commit 1a28687

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/toolkit/src/query/core/buildThunks.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,16 +480,18 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
480480
const fulfilledVal = requestState?.fulfilledTimeStamp
481481

482482
// Order of these checks matters.
483-
// In order for `upsertQueryData` to successfully run while an existing request is
484-
/// in flight, we have to check `isForcedQuery` before `status === 'pending'`,
485-
// otherwise `queryThunk` will bail out and not run at all.
486-
487-
// if this is forced, continue
488-
if (isForcedQuery(arg, state)) return true
483+
// In order for `upsertQueryData` to successfully run while an existing request is in flight,
484+
/// we have to check for that first, otherwise `queryThunk` will bail out and not run at all.
485+
const isUpsertQuery =
486+
typeof arg[forceQueryFnSymbol] === 'function' && arg.forceRefetch
487+
if (isUpsertQuery) return true
489488

490489
// Don't retry a request that's currently in-flight
491490
if (requestState?.status === 'pending') return false
492491

492+
// if this is forced, continue
493+
if (isForcedQuery(arg, state)) return true
494+
493495
// Pull from the cache unless we explicitly force refetch or qualify based on time
494496
if (fulfilledVal)
495497
// Value is cached and we didn't specify to refresh, skip it.

0 commit comments

Comments
 (0)