@@ -487,7 +487,7 @@ export function resumeRequest(
487
487
progressiveChunkSize : postponedState . progressiveChunkSize ,
488
488
status : OPEN ,
489
489
fatalError : null ,
490
- nextSegmentId : 0 ,
490
+ nextSegmentId : postponedState . nextSegmentId ,
491
491
allPendingTasks : 0 ,
492
492
pendingRootTasks : 0 ,
493
493
completedRootSegment : null ,
@@ -1019,11 +1019,7 @@ function replaySuspenseBoundary(
1019
1019
}
1020
1020
try {
1021
1021
// We use the safe form because we don't handle suspending here. Only error handling.
1022
- if ( typeof childSlots === 'number' ) {
1023
- resumeNode ( request , task , childSlots , content , - 1 ) ;
1024
- } else {
1025
- renderNode ( request , task , content , - 1 ) ;
1026
- }
1022
+ renderNode ( request , task , content , - 1 ) ;
1027
1023
if ( task . replay . pendingTasks === 1 && task . replay . nodes . length > 0 ) {
1028
1024
throw new Error (
1029
1025
"Couldn't find all resumable slots by key/index during replaying. " +
@@ -1086,56 +1082,27 @@ function replaySuspenseBoundary(
1086
1082
1087
1083
const fallbackKeyPath = [ keyPath [ 0 ] , 'Suspense Fallback ', keyPath [ 2 ] ] ;
1088
1084
1089
- let suspendedFallbackTask ;
1090
1085
// We create suspended task for the fallback because we don't want to actually work
1091
1086
// on it yet in case we finish the main content, so we queue for later.
1092
- if ( typeof fallbackSlots === 'number ') {
1093
- // Resuming directly in the fallback.
1094
- const resumedSegment = createPendingSegment (
1095
- request ,
1096
- 0 ,
1097
- null ,
1098
- task . formatContext ,
1099
- false ,
1100
- false ,
1101
- ) ;
1102
- resumedSegment . id = fallbackSlots ;
1103
- resumedSegment . parentFlushed = true ;
1104
- suspendedFallbackTask = createRenderTask (
1105
- request ,
1106
- null ,
1107
- fallback ,
1108
- - 1 ,
1109
- parentBoundary ,
1110
- resumedSegment ,
1111
- fallbackAbortSet ,
1112
- fallbackKeyPath ,
1113
- task . formatContext ,
1114
- task . legacyContext ,
1115
- task . context ,
1116
- task . treeContext ,
1117
- ) ;
1118
- } else {
1119
- const fallbackReplay = {
1120
- nodes : fallbackNodes ,
1121
- slots : fallbackSlots ,
1122
- pendingTasks : 0 ,
1123
- } ;
1124
- suspendedFallbackTask = createReplayTask (
1125
- request ,
1126
- null ,
1127
- fallbackReplay ,
1128
- fallback ,
1129
- - 1 ,
1130
- parentBoundary ,
1131
- fallbackAbortSet ,
1132
- fallbackKeyPath ,
1133
- task . formatContext ,
1134
- task . legacyContext ,
1135
- task . context ,
1136
- task . treeContext ,
1137
- ) ;
1138
- }
1087
+ const fallbackReplay = {
1088
+ nodes : fallbackNodes ,
1089
+ slots : fallbackSlots ,
1090
+ pendingTasks : 0 ,
1091
+ } ;
1092
+ const suspendedFallbackTask = createReplayTask(
1093
+ request,
1094
+ null,
1095
+ fallbackReplay,
1096
+ fallback,
1097
+ -1,
1098
+ parentBoundary,
1099
+ fallbackAbortSet,
1100
+ fallbackKeyPath,
1101
+ task.formatContext,
1102
+ task.legacyContext,
1103
+ task.context,
1104
+ task.treeContext,
1105
+ );
1139
1106
if (__DEV__) {
1140
1107
suspendedFallbackTask . componentStack = task . componentStack ;
1141
1108
}
@@ -1965,50 +1932,6 @@ function resumeNode(
1965
1932
}
1966
1933
}
1967
1934
1968
- function resumeElement (
1969
- request : Request ,
1970
- task : ReplayTask ,
1971
- keyPath : KeyNode ,
1972
- segmentId : number ,
1973
- prevThenableState : ThenableState | null ,
1974
- type : any ,
1975
- props : Object ,
1976
- ref : any ,
1977
- ) : void {
1978
- const prevReplay = task . replay ;
1979
- const blockedBoundary = task . blockedBoundary ;
1980
- const resumedSegment = createPendingSegment (
1981
- request ,
1982
- 0 ,
1983
- null ,
1984
- task . formatContext ,
1985
- false ,
1986
- false ,
1987
- ) ;
1988
- resumedSegment . id = segmentId ;
1989
- resumedSegment . parentFlushed = true ;
1990
- try {
1991
- // Convert the current ReplayTask to a RenderTask.
1992
- const renderTask : RenderTask = ( task : any ) ;
1993
- renderTask . replay = null ;
1994
- renderTask . blockedSegment = resumedSegment ;
1995
- renderElement ( request , task , keyPath , prevThenableState , type , props , ref ) ;
1996
- resumedSegment . status = COMPLETED ;
1997
- if ( blockedBoundary === null ) {
1998
- request . completedRootSegment = resumedSegment ;
1999
- } else {
2000
- queueCompletedSegment ( blockedBoundary , resumedSegment ) ;
2001
- if ( blockedBoundary . parentFlushed ) {
2002
- request . partialBoundaries . push ( blockedBoundary ) ;
2003
- }
2004
- }
2005
- } finally {
2006
- // Restore to a ReplayTask.
2007
- task . replay = prevReplay ;
2008
- task . blockedSegment = null ;
2009
- }
2010
- }
2011
-
2012
1935
function replayElement (
2013
1936
request : Request ,
2014
1937
task : ReplayTask ,
@@ -2045,29 +1968,15 @@ function replayElement(
2045
1968
const childSlots = node [ 3 ] ;
2046
1969
task . replay = { nodes : childNodes , slots : childSlots , pendingTasks : 1 } ;
2047
1970
try {
2048
- if ( typeof childSlots === 'number' ) {
2049
- // Matched a resumable element.
2050
- resumeElement (
2051
- request ,
2052
- task ,
2053
- keyPath ,
2054
- childSlots ,
2055
- prevThenableState ,
2056
- type ,
2057
- props ,
2058
- ref ,
2059
- ) ;
2060
- } else {
2061
- renderElement (
2062
- request ,
2063
- task ,
2064
- keyPath ,
2065
- prevThenableState ,
2066
- type ,
2067
- props ,
2068
- ref ,
2069
- ) ;
2070
- }
1971
+ renderElement (
1972
+ request ,
1973
+ task ,
1974
+ keyPath ,
1975
+ prevThenableState ,
1976
+ type ,
1977
+ props ,
1978
+ ref ,
1979
+ ) ;
2071
1980
if (
2072
1981
task . replay . pendingTasks === 1 &&
2073
1982
task . replay . nodes . length > 0
@@ -2215,6 +2124,12 @@ function renderNodeDestructiveImpl(
2215
2124
node : ReactNodeList ,
2216
2125
childIndex : number ,
2217
2126
) : void {
2127
+ if ( task . replay !== null && typeof task . replay . slots === 'number' ) {
2128
+ // TODO: Figure out a cheaper place than this hot path to do this check.
2129
+ const resumeSegmentID = task . replay . slots ;
2130
+ resumeNode ( request , task , resumeSegmentID , node , childIndex ) ;
2131
+ return ;
2132
+ }
2218
2133
// Stash the node we're working on. We'll pick up from this task in case
2219
2134
// something suspends.
2220
2135
task . node = node ;
0 commit comments