MCPcopy Create free account
hub / github.com/reactjs/react-rails / pingSuspendedRoot

Function pingSuspendedRoot

lib/assets/react-source/development/react.js:26654–26705  ·  view source on GitHub ↗
(root, thenable, suspendedTime)

Source from the content-addressed store, hash-verified

26652 }
26653 }
26654 function pingSuspendedRoot(root, thenable, suspendedTime) {
26655 var pingCache = root.pingCache;
26656
26657 if (pingCache !== null) {
26658 // The thenable resolved, so we no longer need to memoize, because it will
26659 // never be thrown again.
26660 pingCache.delete(thenable);
26661 }
26662
26663 if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) {
26664 // Received a ping at the same priority level at which we're currently
26665 // rendering. We might want to restart this render. This should mirror
26666 // the logic of whether or not a root suspends once it completes.
26667 // TODO: If we're rendering sync either due to Sync, Batched or expired,
26668 // we should probably never restart.
26669 // If we're suspended with delay, we'll always suspend so we can always
26670 // restart. If we're suspended without any updates, it might be a retry.
26671 // If it's early in the retry we can restart. We can't know for sure
26672 // whether we'll eventually process an update during this render pass,
26673 // but it's somewhat unlikely that we get to a ping before that, since
26674 // getting to the root most update is usually very fast.
26675 if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
26676 // Restart from the root. Don't need to schedule a ping because
26677 // we're already working on this tree.
26678 prepareFreshStack(root, renderExpirationTime$1);
26679 } else {
26680 // Even though we can't restart right now, we might get an
26681 // opportunity later. So we mark this render as having a ping.
26682 workInProgressRootHasPendingPing = true;
26683 }
26684
26685 return;
26686 }
26687
26688 if (!isRootSuspendedAtTime(root, suspendedTime)) {
26689 // The root is no longer suspended at this time.
26690 return;
26691 }
26692
26693 var lastPingedTime = root.lastPingedTime;
26694
26695 if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
26696 // There's already a lower priority ping scheduled.
26697 return;
26698 } // Mark the time at which this ping was scheduled.
26699
26700
26701 root.lastPingedTime = suspendedTime;
26702
26703 ensureRootIsScheduled(root);
26704 schedulePendingInteractions(root, suspendedTime);
26705 }
26706
26707 function retryTimedOutBoundary(boundaryFiber, retryTime) {
26708 // The boundary fiber (a Suspense component or SuspenseList component)

Callers

nothing calls this directly

Calls 4

prepareFreshStackFunction · 0.85
isRootSuspendedAtTimeFunction · 0.85
ensureRootIsScheduledFunction · 0.85

Tested by

no test coverage detected