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

Function retryTask

packages/react-server/src/ReactFlightServer.js:5617–5748  ·  view source on GitHub ↗
(request: Request, task: Task)

Source from the content-addressed store, hash-verified

5615const emptyRoot = {};
5616
5617function retryTask(request: Request, task: Task): void {
5618 if (task.status !== PENDING) {
5619 // We completed this by other means before we had a chance to retry it.
5620 return;
5621 }
5622
5623 const prevCanEmitDebugInfo = canEmitDebugInfo;
5624 task.status = RENDERING;
5625
5626 // We stash the outer parent size so we can restore it when we exit.
5627 const parentSerializedSize = serializedSize;
5628 // We don't reset the serialized size counter from reentry because that indicates that we
5629 // are outlining a model and we actually want to include that size into the parent since
5630 // it will still block the parent row. It only restores to zero at the top of the stack.
5631 try {
5632 // Track the root so we know that we have to emit this object even though it
5633 // already has an ID. This is needed because we might see this object twice
5634 // in the same toJSON if it is cyclic.
5635 modelRoot = task.model;
5636
5637 if (__DEV__) {
5638 // Track that we can emit debug info for the current task.
5639 canEmitDebugInfo = true;
5640 }
5641
5642 // We call the destructive form that mutates this task. That way if something
5643 // suspends again, we can reuse the same task instead of spawning a new one.
5644 const resolvedModel = renderModelDestructive(
5645 request,
5646 task,
5647 emptyRoot,
5648 '',
5649 task.model,
5650 );
5651
5652 if (__DEV__) {
5653 // We're now past rendering this task and future renders will spawn new tasks for their
5654 // debug info.
5655 canEmitDebugInfo = false;
5656 }
5657
5658 // Track the root again for the resolved object.
5659 modelRoot = resolvedModel;
5660
5661 // The keyPath resets at any terminal child node.
5662 task.keyPath = null;
5663 task.implicitSlot = false;
5664
5665 if (__DEV__) {
5666 const currentEnv = (0, request.environmentName)();
5667 if (currentEnv !== task.environmentName) {
5668 request.pendingChunks++;
5669 // The environment changed since we last emitted any debug information for this
5670 // task. We emit an entry that just includes the environment name change.
5671 emitDebugChunk(request, task.id, {env: currentEnv});
5672 }
5673 }
5674 // We've finished rendering. Log the end time.

Callers 3

outlineTaskFunction · 0.70
performWorkFunction · 0.70

Calls 15

getSuspendedThenableFunction · 0.90
renderModelDestructiveFunction · 0.85
emitDebugChunkFunction · 0.85
markOperationEndTimeFunction · 0.85
emitChunkFunction · 0.85
stringifyFunction · 0.85
emitModelChunkFunction · 0.85
callOnAllReadyIfReadyFunction · 0.85
haltTaskFunction · 0.85
finishHaltedTaskFunction · 0.85
finishAbortedTaskFunction · 0.85

Tested by

no test coverage detected