MCPcopy
hub / github.com/facebook/react / retryRenderTask

Function retryRenderTask

packages/react-server/src/ReactFizzServer.js:5169–5322  ·  view source on GitHub ↗
(
  request: Request,
  task: RenderTask,
  segment: Segment,
)

Source from the content-addressed store, hash-verified

5167}
5168
5169function retryRenderTask(
5170 request: Request,
5171 task: RenderTask,
5172 segment: Segment,
5173): void {
5174 if (segment.status !== PENDING) {
5175 // We completed this by other means before we had a chance to retry it.
5176 return;
5177 }
5178
5179 // We track when a Segment is rendering so we can handle aborts while rendering
5180 segment.status = RENDERING;
5181
5182 // We restore the context to what it was when we suspended.
5183 // We don't restore it after we leave because it's likely that we'll end up
5184 // needing a very similar context soon again.
5185 switchContext(task.context);
5186 let prevTaskInDEV = null;
5187 if (__DEV__) {
5188 prevTaskInDEV = currentTaskInDEV;
5189 setCurrentTaskInDEV(task);
5190 }
5191
5192 const childrenLength = segment.children.length;
5193 const chunkLength = segment.chunks.length;
5194 try {
5195 // We call the destructive form that mutates this task. That way if something
5196 // suspends again, we can reuse the same task instead of spawning a new one.
5197
5198 retryNode(request, task);
5199 pushSegmentFinale(
5200 segment.chunks,
5201 request.renderState,
5202 segment.lastPushedText,
5203 segment.textEmbedded,
5204 );
5205
5206 task.abortSet.delete(task);
5207 segment.status = COMPLETED;
5208 finishedSegment(request, task.blockedBoundary, segment);
5209 finishedTask(request, task.blockedBoundary, task.row, segment);
5210 } catch (thrownValue: mixed) {
5211 resetHooksState();
5212
5213 // Reset the write pointers to where we started.
5214 segment.children.length = childrenLength;
5215 segment.chunks.length = chunkLength;
5216
5217 const x =
5218 thrownValue === SuspenseException
5219 ? // This is a special type of exception used for Suspense. For historical
5220 // reasons, the rest of the Suspense implementation expects the thrown
5221 // value to be a thenable, because before `use` existed that was the
5222 // (unstable) API for suspending. This implementation detail can change
5223 // later, once we deprecate the old API in favor of `use`.
5224 getSuspendedThenable()
5225 : request.status === ABORTING
5226 ? request.fatalError

Callers 1

retryTaskFunction · 0.85

Calls 15

switchContextFunction · 0.90
setCurrentTaskInDEVFunction · 0.90
pushSegmentFinaleFunction · 0.90
resetHooksStateFunction · 0.90
getSuspendedThenableFunction · 0.90
retryNodeFunction · 0.85
finishedSegmentFunction · 0.85
finishedTaskFunction · 0.85
getThrownInfoFunction · 0.85
trackPostponeFunction · 0.85
logPostponeFunction · 0.70

Tested by

no test coverage detected