Skip to content

Commit

Permalink
Only compute component stacks in DEV and prerenders
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Dec 19, 2023
1 parent cb24396 commit de0af49
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
Expand Down

0 comments on commit de0af49

Please sign in to comment.