Skip to content

Commit 2630ac9

Browse files
committed
allow rejected queries to create new subscriptions
1 parent 853b90c commit 2630ac9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ export function buildSlice({
374374
.addCase(
375375
queryThunk.rejected,
376376
(draft, { meta: { condition, arg, requestId }, error, payload }) => {
377-
const substate = draft[arg.queryCacheKey]
378377
// request was aborted due to condition (another query already running)
379-
if (condition && arg.subscribe && substate) {
378+
if (condition && arg.subscribe) {
379+
const substate = (draft[arg.queryCacheKey] ??= {})
380380
substate[requestId] =
381381
arg.subscriptionOptions ?? substate[requestId] ?? {}
382382
}

0 commit comments

Comments
 (0)