Skip to content

Commit

Permalink
fix(graphcache): Fix offlineExchange’s failed queue not being filtere…
Browse files Browse the repository at this point in the history
…d for teardowns (#3236)
  • Loading branch information
kitten authored May 31, 2023
1 parent 9bf5583 commit 0f4fadd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-dodos-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@urql/exchange-graphcache': patch
---

Fix torn down queries not being removed from `offlineExchange`’s failed queue on rehydration.
4 changes: 4 additions & 0 deletions exchanges/graphcache/src/offlineExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export const offlineExchange =
onPush(operation => {
if (operation.kind === 'query' && !hasRehydrated) {
failedQueue.push(operation);
} else if (operation.kind === 'teardown') {
for (let i = failedQueue.length - 1; i >= 0; i--)
if (failedQueue[i].key === operation.key)
failedQueue.splice(i, 1);
}
})
),
Expand Down

0 comments on commit 0f4fadd

Please sign in to comment.