Fix bug where resolved promise was being reused
@@ -278,7 +278,15 @@ function getPromiseForActiveRequest(
resolveOnNext = true;
});
if (RelayFeatureFlags.USE_REACT_CACHE) {
+ // React Suspense should get thrown the same promise each time, so we cache it.
+ // However, the promise gets resolved on each payload, so subsequently we need
+ // to provide a new fresh promise that isn't already resolved. (When the feature
+ // flag is off we do this in QueryResource.)
cachedRequest.promise = promise;
+ const cleanup = () => {
+ cachedRequest.promise = null;
+ };
+ promise.then(cleanup, cleanup);
}
return promise;
}
