@@ -169,8 +169,6 @@ import {Dispatcher, DispatcherWithoutHooks} from './ReactFiberDispatcher';
169169
170170export type Thenable = {
171171 then ( resolve : ( ) => mixed , reject ?: ( ) => mixed ) : mixed ,
172- _reactPingCache : Map < FiberRoot , Set < ExpirationTime> > | void ,
173- _reactRetryCache : Set < Fiber > | void ,
174172} ;
175173
176174const { ReactCurrentOwner} = ReactSharedInternals ;
@@ -1643,9 +1641,21 @@ function renderDidError() {
16431641 nextRenderDidError = true ;
16441642}
16451643
1646- function pingSuspendedRoot ( root : FiberRoot , pingTime : ExpirationTime ) {
1644+ function pingSuspendedRoot (
1645+ root : FiberRoot ,
1646+ thenable : Thenable ,
1647+ pingTime : ExpirationTime ,
1648+ ) {
16471649 // A promise that previously suspended React from committing has resolved.
16481650 // If React is still suspended, try again at the previous level (pingTime).
1651+
1652+ const pingCache = root . pingCache ;
1653+ if ( pingCache !== null ) {
1654+ // The thenable resolved, so we no longer need to memoize, because it will
1655+ // never be thrown again.
1656+ pingCache . delete ( thenable ) ;
1657+ }
1658+
16491659 if ( nextRoot !== null && nextRenderExpirationTime === pingTime ) {
16501660 // Received a ping at the same priority level at which we're currently
16511661 // rendering. Restart from the root.
@@ -1663,11 +1673,20 @@ function pingSuspendedRoot(root: FiberRoot, pingTime: ExpirationTime) {
16631673 }
16641674}
16651675
1666- function retryTimedOutBoundary ( boundaryFiber : Fiber ) {
1676+ function retryTimedOutBoundary ( boundaryFiber : Fiber , thenable : Thenable ) {
16671677 // The boundary fiber (a Suspense component) previously timed out and was
16681678 // rendered in its fallback state. One of the promises that suspended it has
16691679 // resolved, which means at least part of the tree was likely unblocked. Try
16701680 // rendering again, at a new expiration time.
1681+
1682+ const retryCache : WeakSet < Thenable > | Set< Thenable > | null =
1683+ boundaryFiber.stateNode;
1684+ if (retryCache !== null) {
1685+ // The thenable resolved, so we no longer need to memoize, because it will
1686+ // never be thrown again.
1687+ retryCache . delete ( thenable ) ;
1688+ }
1689+
16711690 const currentTime = requestCurrentTime();
16721691 const retryTime = computeExpirationForFiber(currentTime, boundaryFiber);
16731692 const root = scheduleWorkToRoot(boundaryFiber, retryTime);
0 commit comments