From 85aff83f759a670999b525da52e58395194fb5ff Mon Sep 17 00:00:00 2001 From: Duc Nghiem-Xuan <git@ducnx.com> Date: Mon, 9 Sep 2024 16:28:54 +0900 Subject: [PATCH] fix(graphcache): mutation would cause dependent operations and reexecuting operations become the same set The PR #2761 moved `reexecutingOperations = dependentOperations` assignment into `if (operation.kind === 'query')` guard. Thus after a completion of mutation, `dependentOperations = _reexecutingOperations` make reexecuting and dependent operations the same set object. --- exchanges/graphcache/src/cacheExchange.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exchanges/graphcache/src/cacheExchange.ts b/exchanges/graphcache/src/cacheExchange.ts index 260ca9db47..0b14caee68 100644 --- a/exchanges/graphcache/src/cacheExchange.ts +++ b/exchanges/graphcache/src/cacheExchange.ts @@ -136,8 +136,9 @@ export const cacheExchange = // Upon completion, all dependent operations become reexecuting operations, preventing // them from reexecuting prior operations again, causing infinite loops const _reexecutingOperations = reexecutingOperations; + reexecutingOperations = dependentOperations; if (operation.kind === 'query') { - (reexecutingOperations = dependentOperations).add(operation.key); + reexecutingOperations.add(operation.key); } (dependentOperations = _reexecutingOperations).clear(); }