Skip to content

Commit

Permalink
Fix bug where resolved promise was being reused
Browse files Browse the repository at this point in the history
Reviewed By: tyao1

Differential Revision: D38402782

fbshipit-source-id: 0da4d39d22ea20416a970fb0f17a7bd502777af4
  • Loading branch information
davidmccabe authored and facebook-github-bot committed Aug 4, 2022
1 parent 9582ec7 commit 196a57b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/relay-runtime/query/fetchQueryInternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 196a57b

Please sign in to comment.