@@ -169,8 +169,6 @@ import {Dispatcher, DispatcherWithoutHooks} from './ReactFiberDispatcher';
169
169
170
170
export type Thenable = {
171
171
then ( resolve : ( ) => mixed , reject ?: ( ) => mixed ) : mixed ,
172
- _reactPingCache : Map < FiberRoot , Set < ExpirationTime> > | void ,
173
- _reactRetryCache : Set < Fiber > | void ,
174
172
} ;
175
173
176
174
const { ReactCurrentOwner} = ReactSharedInternals ;
@@ -1643,9 +1641,21 @@ function renderDidError() {
1643
1641
nextRenderDidError = true ;
1644
1642
}
1645
1643
1646
- function pingSuspendedRoot ( root : FiberRoot , pingTime : ExpirationTime ) {
1644
+ function pingSuspendedRoot (
1645
+ root : FiberRoot ,
1646
+ thenable : Thenable ,
1647
+ pingTime : ExpirationTime ,
1648
+ ) {
1647
1649
// A promise that previously suspended React from committing has resolved.
1648
1650
// 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
+
1649
1659
if ( nextRoot !== null && nextRenderExpirationTime === pingTime ) {
1650
1660
// Received a ping at the same priority level at which we're currently
1651
1661
// rendering. Restart from the root.
@@ -1663,11 +1673,20 @@ function pingSuspendedRoot(root: FiberRoot, pingTime: ExpirationTime) {
1663
1673
}
1664
1674
}
1665
1675
1666
- function retryTimedOutBoundary ( boundaryFiber : Fiber ) {
1676
+ function retryTimedOutBoundary ( boundaryFiber : Fiber , thenable : Thenable ) {
1667
1677
// The boundary fiber (a Suspense component) previously timed out and was
1668
1678
// rendered in its fallback state. One of the promises that suspended it has
1669
1679
// resolved, which means at least part of the tree was likely unblocked. Try
1670
1680
// 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
+
1671
1690
const currentTime = requestCurrentTime();
1672
1691
const retryTime = computeExpirationForFiber(currentTime, boundaryFiber);
1673
1692
const root = scheduleWorkToRoot(boundaryFiber, retryTime);
0 commit comments