Skip to content

Commit f2094ee

Browse files
committed
[Fizz] Only compute component stacks in DEV and prerenders (#27850)
If you have a lot of intentional throws (or postpones) from client-only rendering then computing the stack is too much. DiffTrain build for [c5b9375](c5b9375)
1 parent beb4a4d commit f2094ee

9 files changed

+112
-75
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cb2439624f43c510007f65aea5c50a8bb97917e4
1+
c5b9375767e2c4102d7e5559d383523736f1c902

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (__DEV__) {
2424
) {
2525
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2626
}
27-
var ReactVersion = "18.3.0-www-modern-2525a22c";
27+
var ReactVersion = "18.3.0-www-modern-b06e722a";
2828

2929
// ATTENTION
3030
// When adding new symbols to this file,

compiled/facebook-www/ReactDOMServer-dev.classic.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-classic-806ab62c";
22+
var ReactVersion = "18.3.0-www-classic-350ad947";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -11034,8 +11034,11 @@ if (__DEV__) {
1103411034
// of the request is less critical than the observability of the execution. For renders and resumes however we
1103511035
// prioritize speed of the request.
1103611036

11037-
function getThrownInfo(node) {
11038-
if (node) {
11037+
function getThrownInfo(request, node) {
11038+
if (
11039+
node && // Always produce a stack in dev
11040+
true
11041+
) {
1103911042
return {
1104011043
componentStack: getStackFromNode(node)
1104111044
};
@@ -11212,7 +11215,7 @@ if (__DEV__) {
1121211215
} catch (error) {
1121311216
contentRootSegment.status = ERRORED;
1121411217
newBoundary.status = CLIENT_RENDERED;
11215-
var thrownInfo = getThrownInfo(task.componentStack);
11218+
var thrownInfo = getThrownInfo(request, task.componentStack);
1121611219
var errorDigest;
1121711220

1121811221
{
@@ -11354,7 +11357,7 @@ if (__DEV__) {
1135411357
}
1135511358
} catch (error) {
1135611359
resumedBoundary.status = CLIENT_RENDERED;
11357-
var thrownInfo = getThrownInfo(task.componentStack);
11360+
var thrownInfo = getThrownInfo(request, task.componentStack);
1135811361
var errorDigest;
1135911362

1136011363
{
@@ -12272,7 +12275,7 @@ if (__DEV__) {
1227212275
// replay nodes which might be Suspense boundaries which are able to
1227312276
// absorb the error and we can still continue with siblings.
1227412277

12275-
var thrownInfo = getThrownInfo(task.componentStack);
12278+
var thrownInfo = getThrownInfo(request, task.componentStack);
1227612279
erroredReplay(
1227712280
request,
1227812281
task.blockedBoundary,
@@ -12621,7 +12624,7 @@ if (__DEV__) {
1262112624
// absorb the error and we can still continue with siblings.
1262212625
// This is an error, stash the component stack if it is null.
1262312626

12624-
var thrownInfo = getThrownInfo(task.componentStack);
12627+
var thrownInfo = getThrownInfo(request, task.componentStack);
1262512628
erroredReplay(
1262612629
request,
1262712630
task.blockedBoundary,
@@ -13117,7 +13120,7 @@ if (__DEV__) {
1311713120
boundary.status = CLIENT_RENDERED; // We construct an errorInfo from the boundary's componentStack so the error in dev will indicate which
1311813121
// boundary the message is referring to
1311913122

13120-
var _errorInfo = getThrownInfo(task.componentStack);
13123+
var _errorInfo = getThrownInfo(request, task.componentStack);
1312113124

1312213125
var _errorDigest = logRecoverableError(request, error, _errorInfo);
1312313126

@@ -13402,7 +13405,7 @@ if (__DEV__) {
1340213405
}
1340313406
}
1340413407

13405-
var errorInfo = getThrownInfo(task.componentStack);
13408+
var errorInfo = getThrownInfo(request, task.componentStack);
1340613409
task.abortSet.delete(task);
1340713410
segment.status = ERRORED;
1340813411
erroredTask(request, task.blockedBoundary, x, errorInfo);
@@ -13487,7 +13490,7 @@ if (__DEV__) {
1348713490

1348813491
task.replay.pendingTasks--;
1348913492
task.abortSet.delete(task);
13490-
var errorInfo = getThrownInfo(task.componentStack);
13493+
var errorInfo = getThrownInfo(request, task.componentStack);
1349113494
erroredReplay(
1349213495
request,
1349313496
task.blockedBoundary,

compiled/facebook-www/ReactDOMServer-dev.modern.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-modern-50304adb";
22+
var ReactVersion = "18.3.0-www-modern-73b83dcd";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -10773,8 +10773,11 @@ if (__DEV__) {
1077310773
// of the request is less critical than the observability of the execution. For renders and resumes however we
1077410774
// prioritize speed of the request.
1077510775

10776-
function getThrownInfo(node) {
10777-
if (node) {
10776+
function getThrownInfo(request, node) {
10777+
if (
10778+
node && // Always produce a stack in dev
10779+
true
10780+
) {
1077810781
return {
1077910782
componentStack: getStackFromNode(node)
1078010783
};
@@ -10951,7 +10954,7 @@ if (__DEV__) {
1095110954
} catch (error) {
1095210955
contentRootSegment.status = ERRORED;
1095310956
newBoundary.status = CLIENT_RENDERED;
10954-
var thrownInfo = getThrownInfo(task.componentStack);
10957+
var thrownInfo = getThrownInfo(request, task.componentStack);
1095510958
var errorDigest;
1095610959

1095710960
{
@@ -11093,7 +11096,7 @@ if (__DEV__) {
1109311096
}
1109411097
} catch (error) {
1109511098
resumedBoundary.status = CLIENT_RENDERED;
11096-
var thrownInfo = getThrownInfo(task.componentStack);
11099+
var thrownInfo = getThrownInfo(request, task.componentStack);
1109711100
var errorDigest;
1109811101

1109911102
{
@@ -12000,7 +12003,7 @@ if (__DEV__) {
1200012003
// replay nodes which might be Suspense boundaries which are able to
1200112004
// absorb the error and we can still continue with siblings.
1200212005

12003-
var thrownInfo = getThrownInfo(task.componentStack);
12006+
var thrownInfo = getThrownInfo(request, task.componentStack);
1200412007
erroredReplay(
1200512008
request,
1200612009
task.blockedBoundary,
@@ -12349,7 +12352,7 @@ if (__DEV__) {
1234912352
// absorb the error and we can still continue with siblings.
1235012353
// This is an error, stash the component stack if it is null.
1235112354

12352-
var thrownInfo = getThrownInfo(task.componentStack);
12355+
var thrownInfo = getThrownInfo(request, task.componentStack);
1235312356
erroredReplay(
1235412357
request,
1235512358
task.blockedBoundary,
@@ -12845,7 +12848,7 @@ if (__DEV__) {
1284512848
boundary.status = CLIENT_RENDERED; // We construct an errorInfo from the boundary's componentStack so the error in dev will indicate which
1284612849
// boundary the message is referring to
1284712850

12848-
var _errorInfo = getThrownInfo(task.componentStack);
12851+
var _errorInfo = getThrownInfo(request, task.componentStack);
1284912852

1285012853
var _errorDigest = logRecoverableError(request, error, _errorInfo);
1285112854

@@ -13130,7 +13133,7 @@ if (__DEV__) {
1313013133
}
1313113134
}
1313213135

13133-
var errorInfo = getThrownInfo(task.componentStack);
13136+
var errorInfo = getThrownInfo(request, task.componentStack);
1313413137
task.abortSet.delete(task);
1313513138
segment.status = ERRORED;
1313613139
erroredTask(request, task.blockedBoundary, x, errorInfo);
@@ -13215,7 +13218,7 @@ if (__DEV__) {
1321513218

1321613219
task.replay.pendingTasks--;
1321713220
task.abortSet.delete(task);
13218-
var errorInfo = getThrownInfo(task.componentStack);
13221+
var errorInfo = getThrownInfo(request, task.componentStack);
1321913222
erroredReplay(
1322013223
request,
1322113224
task.blockedBoundary,

compiled/facebook-www/ReactDOMServer-prod.classic.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,24 +3550,24 @@ function createPendingSegment(
35503550
function createBuiltInComponentStack(task, type) {
35513551
return { tag: 0, parent: task.componentStack, type: type };
35523552
}
3553-
function getThrownInfo(node) {
3554-
if (node) {
3553+
function getThrownInfo(request, node) {
3554+
if (node && null !== request.trackedPostpones) {
35553555
try {
3556-
var info = "";
3556+
request = "";
35573557
do {
35583558
switch (node.tag) {
35593559
case 0:
3560-
info += describeBuiltInComponentFrame(node.type, null, null);
3560+
request += describeBuiltInComponentFrame(node.type, null, null);
35613561
break;
35623562
case 1:
3563-
info += describeNativeComponentFrame(node.type, !1);
3563+
request += describeNativeComponentFrame(node.type, !1);
35643564
break;
35653565
case 2:
3566-
info += describeNativeComponentFrame(node.type, !0);
3566+
request += describeNativeComponentFrame(node.type, !0);
35673567
}
35683568
node = node.parent;
35693569
} while (node);
3570-
var JSCompiler_temp = info;
3570+
var JSCompiler_temp = request;
35713571
} catch (x) {
35723572
JSCompiler_temp =
35733573
"\nError generating stack: " + x.message + "\n" + x.stack;
@@ -3972,7 +3972,10 @@ function renderElement(
39723972
} catch (error) {
39733973
(contentRootSegment.status = 4),
39743974
(ref.status = 4),
3975-
(previousComponentStack = getThrownInfo(task.componentStack)),
3975+
(previousComponentStack = getThrownInfo(
3976+
request,
3977+
task.componentStack
3978+
)),
39763979
(JSCompiler_inline_result = logRecoverableError(
39773980
request,
39783981
error,
@@ -4235,7 +4238,7 @@ function renderNodeDestructive(
42354238
)
42364239
throw (task.node === node && (task.replay = replay), x);
42374240
task.replay.pendingTasks--;
4238-
props = getThrownInfo(task.componentStack);
4241+
props = getThrownInfo(request, task.componentStack);
42394242
key = request;
42404243
request = task.blockedBoundary;
42414244
prevThenableState = x;
@@ -4311,7 +4314,10 @@ function renderNodeDestructive(
43114314
}
43124315
} catch (error) {
43134316
(resumedBoundary.status = 4),
4314-
(childNodes = getThrownInfo(task.componentStack)),
4317+
(childNodes = getThrownInfo(
4318+
request,
4319+
task.componentStack
4320+
)),
43154321
(replay = logRecoverableError(
43164322
request,
43174323
error,
@@ -4475,7 +4481,7 @@ function renderChildrenArray(request, task, children, childIndex) {
44754481
)
44764482
throw x;
44774483
task.replay.pendingTasks--;
4478-
children = getThrownInfo(task.componentStack);
4484+
children = getThrownInfo(request, task.componentStack);
44794485
var boundary = task.blockedBoundary,
44804486
error = x;
44814487
children = logRecoverableError(request, error, children);
@@ -4714,7 +4720,7 @@ function abortTask(task, request, error) {
47144720
boundary.pendingTasks--,
47154721
4 !== boundary.status &&
47164722
((boundary.status = 4),
4717-
(task = getThrownInfo(task.componentStack)),
4723+
(task = getThrownInfo(request, task.componentStack)),
47184724
(task = logRecoverableError(request, error, task)),
47194725
(boundary.errorDigest = task),
47204726
boundary.parentFlushed &&
@@ -4911,7 +4917,10 @@ function performWork(request$jscomp$2) {
49114917
} else {
49124918
task.replay.pendingTasks--;
49134919
task.abortSet.delete(task);
4914-
var errorInfo = getThrownInfo(task.componentStack);
4920+
var errorInfo = getThrownInfo(
4921+
request$jscomp$0,
4922+
task.componentStack
4923+
);
49154924
request = void 0;
49164925
var request$jscomp$1 = request$jscomp$0,
49174926
boundary = task.blockedBoundary,
@@ -4984,7 +4993,10 @@ function performWork(request$jscomp$2) {
49844993
x$jscomp$0.then(ping$jscomp$0, ping$jscomp$0);
49854994
task.thenableState = getThenableStateAfterSuspending();
49864995
} else {
4987-
var errorInfo$jscomp$0 = getThrownInfo(task.componentStack);
4996+
var errorInfo$jscomp$0 = getThrownInfo(
4997+
request,
4998+
task.componentStack
4999+
);
49885000
task.abortSet.delete(task);
49895001
request$jscomp$1.status = 4;
49905002
var boundary$jscomp$0 = task.blockedBoundary;
@@ -5652,4 +5664,4 @@ exports.renderToString = function (children, options) {
56525664
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
56535665
);
56545666
};
5655-
exports.version = "18.3.0-www-classic-1005353c";
5667+
exports.version = "18.3.0-www-classic-ef6a5528";

0 commit comments

Comments
 (0)