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

Function erroredTask

packages/react-server/src/ReactFizzServer.js:4448–4526  ·  view source on GitHub ↗
(
  request: Request,
  boundary: Root | SuspenseBoundary,
  row: null | SuspenseListRow,
  error: mixed,
  errorInfo: ThrownInfo,
  debugTask: null | ConsoleTask,
)

Source from the content-addressed store, hash-verified

4446}
4447
4448function erroredTask(
4449 request: Request,
4450 boundary: Root | SuspenseBoundary,
4451 row: null | SuspenseListRow,
4452 error: mixed,
4453 errorInfo: ThrownInfo,
4454 debugTask: null | ConsoleTask,
4455) {
4456 if (row !== null) {
4457 if (--row.pendingTasks === 0) {
4458 finishSuspenseListRow(request, row);
4459 }
4460 }
4461
4462 request.allPendingTasks--;
4463
4464 // Report the error to a global handler.
4465 let errorDigest;
4466 // We don't handle halts here because we only halt when prerendering and
4467 // when prerendering we should be finishing tasks not erroring them when
4468 // they halt or postpone
4469 if (
4470 enablePostpone &&
4471 typeof error === 'object' &&
4472 error !== null &&
4473 error.$$typeof === REACT_POSTPONE_TYPE
4474 ) {
4475 const postponeInstance: Postpone = (error: any);
4476 logPostpone(request, postponeInstance.message, errorInfo, debugTask);
4477 // TODO: Figure out a better signal than a magic digest value.
4478 errorDigest = 'POSTPONE';
4479 } else {
4480 errorDigest = logRecoverableError(request, error, errorInfo, debugTask);
4481 }
4482 if (boundary === null) {
4483 fatalError(request, error, errorInfo, debugTask);
4484 } else {
4485 boundary.pendingTasks--;
4486 if (boundary.status !== CLIENT_RENDERED) {
4487 boundary.status = CLIENT_RENDERED;
4488 encodeErrorForBoundary(boundary, errorDigest, error, errorInfo, false);
4489 untrackBoundary(request, boundary);
4490
4491 const boundaryRow = boundary.row;
4492 if (boundaryRow !== null) {
4493 // Unblock the SuspenseListRow that was blocked by this boundary.
4494 if (--boundaryRow.pendingTasks === 0) {
4495 finishSuspenseListRow(request, boundaryRow);
4496 }
4497 }
4498
4499 // Regardless of what happens next, this boundary won't be displayed,
4500 // so we can flush it, if the parent already flushed.
4501 if (boundary.parentFlushed) {
4502 // We don't have a preference where in the queue this goes since it's likely
4503 // to error on the client anyway. However, intentionally client-rendered
4504 // boundaries should be flushed earlier so that they can start on the client.
4505 // We reuse the same queue for errors.

Callers 1

retryRenderTaskFunction · 0.70

Calls 9

finishSuspenseListRowFunction · 0.85
encodeErrorForBoundaryFunction · 0.85
untrackBoundaryFunction · 0.85
preparePreambleFunction · 0.85
completeAllFunction · 0.85
logPostponeFunction · 0.70
logRecoverableErrorFunction · 0.70
fatalErrorFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected