diff --git a/.changeset/pretty-dodos-happen.md b/.changeset/pretty-dodos-happen.md new file mode 100644 index 0000000000..62776fa31a --- /dev/null +++ b/.changeset/pretty-dodos-happen.md @@ -0,0 +1,5 @@ +--- +'@urql/exchange-graphcache': patch +--- + +Fix torn down queries not being removed from `offlineExchange`’s failed queue on rehydration. diff --git a/exchanges/graphcache/src/offlineExchange.ts b/exchanges/graphcache/src/offlineExchange.ts index 194421f0ea..05e07de73b 100644 --- a/exchanges/graphcache/src/offlineExchange.ts +++ b/exchanges/graphcache/src/offlineExchange.ts @@ -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); } }) ),