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

Function abortTask

packages/react-server/src/ReactFizzServer.js:4637–4875  ·  view source on GitHub ↗
(task: Task, request: Request, error: mixed)

Source from the content-addressed store, hash-verified

4635}
4636
4637function abortTask(task: Task, request: Request, error: mixed): void {
4638 // This aborts the task and aborts the parent that it blocks, putting it into
4639 // client rendered mode.
4640 const boundary = task.blockedBoundary;
4641 const segment = task.blockedSegment;
4642 if (segment !== null) {
4643 if (segment.status === RENDERING) {
4644 // This is the a currently rendering Segment. The render itself will
4645 // abort the task.
4646 return;
4647 }
4648 segment.status = ABORTED;
4649 }
4650
4651 const errorInfo = getThrownInfo(task.componentStack);
4652 if (__DEV__ && enableAsyncDebugInfo) {
4653 // If the task is not rendering, then this is an async abort. Conceptually it's as if
4654 // the abort happened inside the async gap. The abort reason's stack frame won't have that
4655 // on the stack so instead we use the owner stack and debug task of any halted async debug info.
4656 const node: any = task.node;
4657 if (node !== null && typeof node === 'object') {
4658 // Push a fake component stack frame that represents the await.
4659 pushHaltedAwaitOnComponentStack(task, node._debugInfo);
4660 /*
4661 if (task.thenableState !== null) {
4662 // TODO: If we were stalled inside use() of a Client Component then we should
4663 // rerender to get the stack trace from the use() call.
4664 }
4665 */
4666 }
4667 }
4668
4669 if (boundary === null) {
4670 if (request.status !== CLOSING && request.status !== CLOSED) {
4671 const replay: null | ReplaySet = task.replay;
4672 if (replay === null) {
4673 // We didn't complete the root so we have nothing to show. We can close
4674 // the request;
4675 if (
4676 enablePostpone &&
4677 typeof error === 'object' &&
4678 error !== null &&
4679 error.$$typeof === REACT_POSTPONE_TYPE
4680 ) {
4681 const postponeInstance: Postpone = (error: any);
4682 const trackedPostpones = request.trackedPostpones;
4683
4684 if (trackedPostpones !== null && segment !== null) {
4685 // We are prerendering. We don't want to fatal when the shell postpones
4686 // we just need to mark it as postponed.
4687 logPostpone(
4688 request,
4689 postponeInstance.message,
4690 errorInfo,
4691 task.debugTask,
4692 );
4693 trackPostpone(request, trackedPostpones, task, segment);
4694 finishedTask(request, null, task.row, segment);

Callers 2

abortTaskDEVFunction · 0.70
abortFunction · 0.70

Calls 15

getThrownInfoFunction · 0.85
trackPostponeFunction · 0.85
finishedTaskFunction · 0.85
completeShellFunction · 0.85
encodeErrorForBoundaryFunction · 0.85
untrackBoundaryFunction · 0.85
finishSuspenseListRowFunction · 0.85
completeAllFunction · 0.85
logPostponeFunction · 0.70
logRecoverableErrorFunction · 0.70

Tested by

no test coverage detected