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

Code before:
    }
  }
  const lazyType: LazyComponent<any, Thenable<any>> = {
    $$typeof: REACT_LAZY_TYPE,
    _payload: thenable,
    _init: readThenable,
  };
  if (__DEV__) {
    // If this came from React, transfer the debug info.
    lazyType._debugInfo = (thenable: any)._debugInfo || [];
  }
  return lazyType;
}

function callWithDebugContextInDEV<A, T>(
  request: Request,
  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 = {
    name: null,
    env: task.environmentName,
    owner: task.debugOwner,
  };
  if (enableOwnerStacks) {
    // $FlowFixMe[cannot-write]
    componentDebugInfo.stack =
      task.debugStack === null
        ? null
        : filterStackTrace(request, task.debugStack, 1);
    // $FlowFixMe[cannot-write]
    componentDebugInfo.debugStack = task.debugStack;
    // $FlowFixMe[cannot-write]
    componentDebugInfo.debugTask = task.debugTask;
  }
  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);

Review comment (bug):
Found a bug with the previous isReactComponentInfo check and this hack. Since this doesn't have a name of a component is wasn't being detected. Since this is not outlined it also goes through the renderConsoleValue path.

Code after:
    }
  }
  const lazyType: LazyComponent<any, Thenable<any>> = {
    $$typeof: REACT_LAZY_TYPE,
    _payload: thenable,
    _init: readThenable,
  };
  if (__DEV__) {
    // If this came from React, transfer the debug info.
    lazyType._debugInfo = (thenable: any)._debugInfo || [];
  }
  return lazyType;
}

function callWithDebugContextInDEV<A, T>(
  request: Request,
  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 = {
    name: '',
    env: task.environmentName,
    owner: task.debugOwner,
  };
  if (enableOwnerStacks) {
    // $FlowFixMe[cannot-write]
    componentDebugInfo.stack =
      task.debugStack === null
        ? null
        : filterStackTrace(request, task.debugStack, 1);
    // $FlowFixMe[cannot-write]
    componentDebugInfo.debugStack = task.debugStack;
    // $FlowFixMe[cannot-write]
    componentDebugInfo.debugTask = task.debugTask;
  }
  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);