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

Function abortRemainingReplayNodes

packages/react-server/src/ReactFizzServer.js:4574–4635  ·  view source on GitHub ↗
(
  request: Request,
  boundary: Root | SuspenseBoundary,
  nodes: Array<ReplayNode>,
  slots: ResumeSlots,
  error: mixed,
  errorDigest: ?string,
  errorInfo: ThrownInfo,
  aborted: boolean,
)

Source from the content-addressed store, hash-verified

4572}
4573
4574function abortRemainingReplayNodes(
4575 request: Request,
4576 boundary: Root | SuspenseBoundary,
4577 nodes: Array<ReplayNode>,
4578 slots: ResumeSlots,
4579 error: mixed,
4580 errorDigest: ?string,
4581 errorInfo: ThrownInfo,
4582 aborted: boolean,
4583): void {
4584 for (let i = 0; i < nodes.length; i++) {
4585 const node = nodes[i];
4586 if (node.length === 4) {
4587 abortRemainingReplayNodes(
4588 request,
4589 boundary,
4590 node[2],
4591 node[3],
4592 error,
4593 errorDigest,
4594 errorInfo,
4595 aborted,
4596 );
4597 } else {
4598 const boundaryNode: ReplaySuspenseBoundary = node;
4599 const rootSegmentID = boundaryNode[5];
4600 abortRemainingSuspenseBoundary(
4601 request,
4602 rootSegmentID,
4603 error,
4604 errorDigest,
4605 errorInfo,
4606 aborted,
4607 );
4608 }
4609 }
4610 // Empty the set, since we've cleared it now.
4611 nodes.length = 0;
4612
4613 if (slots !== null) {
4614 // We had something still to resume in the parent boundary. We must trigger
4615 // the error on the parent boundary since it's not able to complete.
4616 if (boundary === null) {
4617 throw new Error(
4618 'We should not have any resumable nodes in the shell. ' +
4619 'This is a bug in React.',
4620 );
4621 } else if (boundary.status !== CLIENT_RENDERED) {
4622 boundary.status = CLIENT_RENDERED;
4623 encodeErrorForBoundary(boundary, errorDigest, error, errorInfo, aborted);
4624 if (boundary.parentFlushed) {
4625 request.clientRenderedBoundaries.push(boundary);
4626 }
4627 }
4628 // Empty the set
4629 if (typeof slots === 'object') {
4630 for (const index in slots) {
4631 delete slots[(index: any)];

Callers 2

erroredReplayFunction · 0.85
abortTaskFunction · 0.85

Calls 3

encodeErrorForBoundaryFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected