Repository: facebook/react
File: packages/react-server/src/ReactFizzServer.js (JavaScript)

Code before:
}

function abortTask(task: Task, request: Request, error: mixed): void {
  // This aborts the task and aborts the parent that it blocks, putting it into
  // client rendered mode.
  const boundary = task.blockedBoundary;
  const segment = task.blockedSegment;
  if (segment !== null) {
    if (segment.status === RENDERING) {
      // This is the a currently rendering Segment. The render itself will
      // abort the task.
      return;
    }
    segment.status = ABORTED;
  }

  const errorInfo = getThrownInfo(task.componentStack);
  if (__DEV__ && enableAsyncDebugInfo) {
    // If the task is not rendering, then this is an async abort. Conceptually it's as if
    // the abort happened inside the async gap. The abort reason's stack frame won't have that
    // on the stack so instead we use the owner stack and debug task of any halted async debug info.
    let node: any = task.node;
    if (node !== null && typeof node === 'object') {
      // Push a fake component stack frame that represents the await.
      let debugInfo = node._debugInfo;
      if (debugInfo == null || debugInfo.length === 0) {
        // If there's no debug info, try resolving lazy components to find debug
        // info that has been transferred to the inner value.
        while (
          typeof node === 'object' &&
          node !== null &&
          node.$$typeof === REACT_LAZY_TYPE
        ) {
          const payload = node._payload;
          if (payload.status === 'fulfilled') {
            node = payload.value;
            continue;
          }
          break;
        }
        if (
          typeof node === 'object' &&
          node !== null &&
          (isArray(node) ||
            typeof node[ASYNC_ITERATOR] === 'function' ||
            node.$$typeof === REACT_ELEMENT_TYPE ||
            node.$$typeof === REACT_LAZY_TYPE) &&
          isArray(node._debugInfo)
        ) {
          debugInfo = node._debugInfo;
        }

Review comment (suggestion):
It might not necessarily be zero in this case. It is right now but we could potentially add other discoveries to the parent. For example, I'm not sure if the RSC stream chunk should really be transferred to the inner since it doesn't block other usages.

Code after:
}

function abortTask(task: Task, request: Request, error: mixed): void {
  // This aborts the task and aborts the parent that it blocks, putting it into
  // client rendered mode.
  const boundary = task.blockedBoundary;
  const segment = task.blockedSegment;
  if (segment !== null) {
    if (segment.status === RENDERING) {
      // This is the a currently rendering Segment. The render itself will
      // abort the task.
      return;
    }
    segment.status = ABORTED;
  }

  const errorInfo = getThrownInfo(task.componentStack);
  if (__DEV__ && enableAsyncDebugInfo) {
    // If the task is not rendering, then this is an async abort. Conceptually it's as if
    // the abort happened inside the async gap. The abort reason's stack frame won't have that
    // on the stack so instead we use the owner stack and debug task of any halted async debug info.
    let node: any = task.node;
    if (node !== null && typeof node === 'object') {
      // Push a fake component stack frame that represents the await.
      let debugInfo = node._debugInfo;
      // First resolve lazy nodes to find debug info that has been transferred
      // to the inner value.
      while (
        typeof node === 'object' &&
        node !== null &&
        node.$$typeof === REACT_LAZY_TYPE
      ) {
        const payload = node._payload;
        if (payload.status === 'fulfilled') {
          node = payload.value;
          continue;
        }
        break;
      }
      if (
        typeof node === 'object' &&
        node !== null &&
        (isArray(node) ||
          typeof node[ASYNC_ITERATOR] === 'function' ||
          node.$$typeof === REACT_ELEMENT_TYPE ||
          node.$$typeof === REACT_LAZY_TYPE) &&
        isArray(node._debugInfo)
      ) {
        debugInfo = node._debugInfo;
      }
      pushHaltedAwaitOnComponentStack(task, debugInfo);