@@ -245,9 +245,9 @@ let legacyErrorBoundariesThatAlreadyFailed: Set<mixed> | null = null;
245
245
// Used for performance tracking.
246
246
let interruptedBy : Fiber | null = null ;
247
247
248
- // Do not increment or decrement interaction counts in the event of suspense timeouts.
249
- // This flag is only used when enableInteractionTracking is true .
250
- let freezeInteractionCount : boolean = false ;
248
+ // Do not decrement interaction counts in the event of suspense timeouts.
249
+ // This would lead to prematurely calling the interaction-complete hook .
250
+ let suspenseDidTimeout : boolean = false ;
251
251
252
252
let stashedWorkInProgressProperties ;
253
253
let replayUnitOfWork ;
@@ -778,7 +778,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
778
778
} finally {
779
779
// Don't update interaction counts if we're frozen due to suspense.
780
780
// In this case, we can skip the completed-work check entirely.
781
- if ( ! freezeInteractionCount ) {
781
+ if ( ! suspenseDidTimeout ) {
782
782
// Now that we're done, check the completed batch of interactions.
783
783
// If no more work is outstanding for a given interaction,
784
784
// We need to notify the subscribers that it's finished.
@@ -1607,9 +1607,8 @@ function retrySuspendedRoot(
1607
1607
__interactionsRef . current = root . memoizedInteractions ;
1608
1608
// Because suspense timeouts do not decrement the interaction count,
1609
1609
// Continued suspense work should also not increment the count.
1610
- freezeInteractionCount = true ;
1610
+ storeInteractionsForExpirationTime ( root , rootExpirationTime , false ) ;
1611
1611
requestWork ( root , rootExpirationTime ) ;
1612
- freezeInteractionCount = false ;
1613
1612
__interactionsRef . current = prevInteractions ;
1614
1613
} else {
1615
1614
requestWork ( root , rootExpirationTime ) ;
@@ -1671,6 +1670,7 @@ function scheduleWorkToRoot(fiber: Fiber, expirationTime): FiberRoot | null {
1671
1670
function storeInteractionsForExpirationTime (
1672
1671
root : FiberRoot ,
1673
1672
expirationTime : ExpirationTime ,
1673
+ updateInteractionCounts : boolean ,
1674
1674
) : void {
1675
1675
if ( ! enableInteractionTracking ) {
1676
1676
return ;
@@ -1681,7 +1681,7 @@ function storeInteractionsForExpirationTime(
1681
1681
const pendingInteractions = root . pendingInteractionMap . get ( expirationTime ) ;
1682
1682
if ( pendingInteractions != null ) {
1683
1683
interactions . forEach ( interaction => {
1684
- if ( ! freezeInteractionCount && ! pendingInteractions . has ( interaction ) ) {
1684
+ if ( updateInteractionCounts && ! pendingInteractions . has ( interaction ) ) {
1685
1685
// Update the pending async work count for previously unscheduled interaction.
1686
1686
interaction . __count ++ ;
1687
1687
}
@@ -1692,7 +1692,7 @@ function storeInteractionsForExpirationTime(
1692
1692
root . pendingInteractionMap . set ( expirationTime , new Set ( interactions ) ) ;
1693
1693
1694
1694
// Update the pending async work count for the current interactions.
1695
- if ( ! freezeInteractionCount ) {
1695
+ if ( updateInteractionCounts ) {
1696
1696
interactions . forEach ( interaction => {
1697
1697
interaction . __count ++ ;
1698
1698
} ) ;
@@ -1732,7 +1732,7 @@ function scheduleWork(fiber: Fiber, expirationTime: ExpirationTime) {
1732
1732
}
1733
1733
1734
1734
if ( enableInteractionTracking ) {
1735
- storeInteractionsForExpirationTime ( root , expirationTime ) ;
1735
+ storeInteractionsForExpirationTime ( root , expirationTime , true ) ;
1736
1736
}
1737
1737
1738
1738
if (
@@ -1845,10 +1845,6 @@ function scheduleCallbackWithExpirationTime(
1845
1845
root : FiberRoot ,
1846
1846
expirationTime : ExpirationTime ,
1847
1847
) {
1848
- if ( enableProfilerTimer ) {
1849
- storeInteractionsForExpirationTime ( root , expirationTime ) ;
1850
- }
1851
-
1852
1848
if ( callbackExpirationTime !== NoWork ) {
1853
1849
// A callback is already scheduled. Check its expiration time (timeout).
1854
1850
if ( expirationTime > callbackExpirationTime ) {
@@ -1929,9 +1925,9 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) {
1929
1925
if ( enableInteractionTracking ) {
1930
1926
// Don't update pending interaction counts for suspense timeouts,
1931
1927
// Because we know we still need to do more work in this case.
1932
- freezeInteractionCount = true ;
1928
+ suspenseDidTimeout = true ;
1933
1929
flushRoot ( root , suspendedExpirationTime ) ;
1934
- freezeInteractionCount = false ;
1930
+ suspenseDidTimeout = false ;
1935
1931
} else {
1936
1932
flushRoot ( root , suspendedExpirationTime ) ;
1937
1933
}
0 commit comments