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

Code before:
    }
  } finally {
    setCurrentOwner(null);
  }
}

// This indirect exists so we can exclude its stack frame in DEV (and anything below it).
/** @noinline */
function callLazyInitInDEV(lazy: LazyComponent<any, any>): any {
  const payload = lazy._payload;
  const init = lazy._init;
  return init(payload);
}

function callWithDebugContextInDEV<A, T>(
  task: Task,
  callback: A => T,
  arg: A,
): T {
  // We don't have a Server Component instance associated with this callback and
  // the nearest context is likely a Client Component being serialized. We create
  // a fake owner during this callback so we can get the stack trace from it.
  // This also gets sent to the client as the owner for the replaying log.
  const componentDebugInfo: ReactComponentInfo = {
    env: task.environmentName,
    owner: task.debugOwner,
  };
  if (enableOwnerStacks) {
    // $FlowFixMe[cannot-write]
    componentDebugInfo.stack = task.debugStack;
  }
  const debugTask = task.debugTask;
  // We don't need the async component storage context here so we only set the
  // synchronous tracking of owner.
  setCurrentOwner(componentDebugInfo);
  try {
    if (enableOwnerStacks && debugTask) {
      if (supportsRequestStorage) {
        // Exit the request context while running callbacks.
        return debugTask.run(
          // $FlowFixMe[method-unbinding]
          requestStorage.run.bind(
            requestStorage,
            undefined,
            callback.bind(null, arg),
          ),
        );
      }
      return debugTask.run(callback.bind(null, arg));
    }
    if (supportsRequestStorage) {

Review comment (bug):
Ideally we'd have the name of the component here too. That's why it shows up as `<...>` in the console task. There's two reasons for this:

1) We don't track the "type". In Fizz we track the parent on ComponentStackNode which has this info. We could potentially eagerly create componentDebugInfo for client components in case they error instead of lazily.
2) We don't have a "name" of ClientReferences atm anyway which is why the error message itself has a `<... `.

Code after:
    }
  } finally {
    setCurrentOwner(null);
  }
}

// This indirect exists so we can exclude its stack frame in DEV (and anything below it).
/** @noinline */
function callLazyInitInDEV(lazy: LazyComponent<any, any>): any {
  const payload = lazy._payload;
  const init = lazy._init;
  return init(payload);
}

function callWithDebugContextInDEV<A, T>(
  task: Task,
  callback: A => T,
  arg: A,
): T {
  // We don't have a Server Component instance associated with this callback and
  // the nearest context is likely a Client Component being serialized. We create
  // a fake owner during this callback so we can get the stack trace from it.
  // This also gets sent to the client as the owner for the replaying log.
  const componentDebugInfo: ReactComponentInfo = {
    env: task.environmentName,
    owner: task.debugOwner,
  };
  if (enableOwnerStacks) {
    // $FlowFixMe[cannot-write]
    componentDebugInfo.stack = task.debugStack;
  }
  const debugTask = task.debugTask;
  // We don't need the async component storage context here so we only set the
  // synchronous tracking of owner.
  setCurrentOwner(componentDebugInfo);
  try {
    if (enableOwnerStacks && debugTask) {
      return debugTask.run(callback.bind(null, arg));
    }
    return callback(arg);
  } finally {
    setCurrentOwner(null);
  }
}

function renderFunctionComponent<Props>(
  request: Request,
  task: Task,
  key: null | string,
  Component: (p: Props, arg: void) => any,
  props: Props,