@@ -1017,11 +1017,6 @@ function abortTask(task: Task): void {
1017
1017
} else {
1018
1018
boundary . pendingTasks -- ;
1019
1019
1020
- // If this boundary was still pending then we haven't already cancelled its fallbacks.
1021
- // We'll need to abort the fallbacks, which will also error that parent boundary.
1022
- boundary . fallbackAbortableTasks . forEach ( abortTask , request ) ;
1023
- boundary . fallbackAbortableTasks . clear ( ) ;
1024
-
1025
1020
if ( ! boundary . forceClientRender ) {
1026
1021
boundary . forceClientRender = true ;
1027
1022
if ( boundary . parentFlushed ) {
@@ -1060,9 +1055,6 @@ function finishedTask(
1060
1055
// This already errored.
1061
1056
} else if ( boundary . pendingTasks === 0 ) {
1062
1057
// This must have been the last segment we were waiting on. This boundary is now complete.
1063
- // We can now cancel any pending task on the fallback since we won't need to show it anymore.
1064
- boundary . fallbackAbortableTasks . forEach ( abortTaskSoft , request ) ;
1065
- boundary . fallbackAbortableTasks . clear ( ) ;
1066
1058
if ( segment . parentFlushed ) {
1067
1059
// Our parent segment already flushed, so we need to schedule this segment to be emitted.
1068
1060
boundary . completedSegments . push ( segment ) ;
@@ -1072,6 +1064,11 @@ function finishedTask(
1072
1064
// parent flushed, we need to schedule the boundary to be emitted.
1073
1065
request . completedBoundaries . push ( boundary ) ;
1074
1066
}
1067
+ // We can now cancel any pending task on the fallback since we won't need to show it anymore.
1068
+ // This needs to happen after we read the parentFlushed flags because aborting can finish
1069
+ // work which can trigger user code, which can start flushing, which can change those flags.
1070
+ boundary . fallbackAbortableTasks . forEach ( abortTaskSoft , request ) ;
1071
+ boundary . fallbackAbortableTasks . clear ( ) ;
1075
1072
} else {
1076
1073
if ( segment . parentFlushed ) {
1077
1074
// Our parent already flushed, so we need to schedule this segment to be emitted.
0 commit comments