diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js index cd34e285b1e74..1e5ce967087af 100644 --- a/packages/react-server/src/ReactFizzServer.js +++ b/packages/react-server/src/ReactFizzServer.js @@ -765,12 +765,27 @@ type ThrownInfo = { export type ErrorInfo = ThrownInfo; export type PostponeInfo = ThrownInfo; +type ThrownInfo = { + componentStack?: string, +}; +export type ErrorInfo = ThrownInfo; +export type PostponeInfo = ThrownInfo; + // While we track component stacks in prod all the time we only produce a reified stack in dev and // during prerender in Prod. The reason for this is that the stack is useful for prerender where the timeliness // of the request is less critical than the observability of the execution. For renders and resumes however we // prioritize speed of the request. -function getThrownInfo(node: null | ComponentStackNode): ThrownInfo { - if (node) { +function getThrownInfo( + request: Request, + node: null | ComponentStackNode, +): ThrownInfo { + if ( + node && + // Always produce a stack in dev + (__DEV__ || + // Produce a stack in prod if we're in a prerender + request.trackedPostpones !== null) + ) { return { componentStack: getStackFromNode(node), };