MCPcopy Create free account
hub / github.com/microsoft/SandDance / pingSuspendedRoot

Function pingSuspendedRoot

docs/external/js/react-dom.development.js:23094–23145  ·  view source on GitHub ↗
(root, thenable, suspendedTime)

Source from the content-addressed store, hash-verified

23092 }
23093 }
23094 function pingSuspendedRoot(root, thenable, suspendedTime) {
23095 var pingCache = root.pingCache;
23096
23097 if (pingCache !== null) {
23098 // The thenable resolved, so we no longer need to memoize, because it will
23099 // never be thrown again.
23100 pingCache.delete(thenable);
23101 }
23102
23103 if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) {
23104 // Received a ping at the same priority level at which we're currently
23105 // rendering. We might want to restart this render. This should mirror
23106 // the logic of whether or not a root suspends once it completes.
23107 // TODO: If we're rendering sync either due to Sync, Batched or expired,
23108 // we should probably never restart.
23109 // If we're suspended with delay, we'll always suspend so we can always
23110 // restart. If we're suspended without any updates, it might be a retry.
23111 // If it's early in the retry we can restart. We can't know for sure
23112 // whether we'll eventually process an update during this render pass,
23113 // but it's somewhat unlikely that we get to a ping before that, since
23114 // getting to the root most update is usually very fast.
23115 if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
23116 // Restart from the root. Don't need to schedule a ping because
23117 // we're already working on this tree.
23118 prepareFreshStack(root, renderExpirationTime$1);
23119 } else {
23120 // Even though we can't restart right now, we might get an
23121 // opportunity later. So we mark this render as having a ping.
23122 workInProgressRootHasPendingPing = true;
23123 }
23124
23125 return;
23126 }
23127
23128 if (!isRootSuspendedAtTime(root, suspendedTime)) {
23129 // The root is no longer suspended at this time.
23130 return;
23131 }
23132
23133 var lastPingedTime = root.lastPingedTime;
23134
23135 if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
23136 // There's already a lower priority ping scheduled.
23137 return;
23138 } // Mark the time at which this ping was scheduled.
23139
23140
23141 root.lastPingedTime = suspendedTime;
23142
23143 ensureRootIsScheduled(root);
23144 schedulePendingInteractions(root, suspendedTime);
23145 }
23146
23147 function retryTimedOutBoundary(boundaryFiber, retryTime) {
23148 // The boundary fiber (a Suspense component or SuspenseList component)

Callers

nothing calls this directly

Calls 6

prepareFreshStackFunction · 0.85
isRootSuspendedAtTimeFunction · 0.85
ensureRootIsScheduledFunction · 0.85
nowFunction · 0.50
deleteMethod · 0.45

Tested by

no test coverage detected