Skip to content

Commit de0af49

Browse files
committed
Only compute component stacks in DEV and prerenders
1 parent cb24396 commit de0af49

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

packages/react-server/src/ReactFizzServer.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,12 +765,27 @@ type ThrownInfo = {
765765
export type ErrorInfo = ThrownInfo;
766766
export type PostponeInfo = ThrownInfo;
767767

768+
type ThrownInfo = {
769+
componentStack?: string,
770+
};
771+
export type ErrorInfo = ThrownInfo;
772+
export type PostponeInfo = ThrownInfo;
773+
768774
// While we track component stacks in prod all the time we only produce a reified stack in dev and
769775
// during prerender in Prod. The reason for this is that the stack is useful for prerender where the timeliness
770776
// of the request is less critical than the observability of the execution. For renders and resumes however we
771777
// prioritize speed of the request.
772-
function getThrownInfo(node: null | ComponentStackNode): ThrownInfo {
773-
if (node) {
778+
function getThrownInfo(
779+
request: Request,
780+
node: null | ComponentStackNode,
781+
): ThrownInfo {
782+
if (
783+
node &&
784+
// Always produce a stack in dev
785+
(__DEV__ ||
786+
// Produce a stack in prod if we're in a prerender
787+
request.trackedPostpones !== null)
788+
) {
774789
return {
775790
componentStack: getStackFromNode(node),
776791
};

0 commit comments

Comments
 (0)