Skip to content

Commit 6535b04

Browse files
committed
Include server component names in the componentStack in DEV (#28415)
I'm a bit ambivalent about this one because it's not the main strategy that I plan on pursuing. I plan on replacing most DEV-only specific stacks like `console.error` stacks with a new take on owner stacks and native stacks. The future owner stacks may or may not be exposed to error boundaries in DEV but if they are they'd be a new errorInfo property since they're owner based and not available in prod. The use case in `console.error` mostly goes away in the future so this PR is mainly for error boundaries. It doesn't hurt to have it in there while I'm working on the better stacks though. The `componentStack` property exposed to error boundaries is more like production behavior similar to `new Error().stack` (which even in DEV won't ever expose owner stacks because `console.createTask` doesn't affect these). I'm not sure it's worth adding server components in DEV (this PR) because then you have forked behavior between dev and prod. However, since even in the future there won't be any other place to get the *parent* stack, maybe this can be useful information even if it's only dev. We could expose a third property on errorInfo that's DEV only and parent stack but including server components. That doesn't seem worth it over just having the stack differ in dev and prod. I don't plan on adding line/column number to these particular stacks. A follow up could be to add this to Fizz prerender too but only in DEV. DiffTrain build for [8fb0233](8fb0233)
1 parent edd8fbe commit 6535b04

11 files changed

+181
-21
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
66c8346401d271588e4c400921c5dab5478fc623
1+
8fb0233a845974b4b1049e54b6c25dc54d6dd173

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,4 +635,4 @@ exports.useSyncExternalStore = function (
635635
exports.useTransition = function () {
636636
return ReactCurrentDispatcher.current.useTransition();
637637
};
638-
exports.version = "18.3.0-www-classic-523eda18";
638+
exports.version = "18.3.0-www-classic-59a8d1a0";

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if (__DEV__) {
6666
return self;
6767
}
6868

69-
var ReactVersion = "18.3.0-www-classic-2f254d96";
69+
var ReactVersion = "18.3.0-www-classic-f7f3772e";
7070

7171
var LegacyRoot = 0;
7272
var ConcurrentRoot = 1;
@@ -5200,6 +5200,11 @@ if (__DEV__) {
52005200
return "\n" + prefix + name;
52015201
}
52025202
}
5203+
function describeDebugInfoFrame(name, env) {
5204+
return describeBuiltInComponentFrame(
5205+
name + (env ? " (" + env + ")" : "")
5206+
);
5207+
}
52035208
var reentry = false;
52045209
var componentFrameCache;
52055210

@@ -5504,7 +5509,22 @@ if (__DEV__) {
55045509
var node = workInProgress;
55055510

55065511
do {
5507-
info += describeFiber(node); // $FlowFixMe[incompatible-type] we bail out when we get a null
5512+
info += describeFiber(node);
5513+
5514+
if (true) {
5515+
// Add any Server Component stack frames in reverse order.
5516+
var debugInfo = node._debugInfo;
5517+
5518+
if (debugInfo) {
5519+
for (var i = debugInfo.length - 1; i >= 0; i--) {
5520+
var entry = debugInfo[i];
5521+
5522+
if (typeof entry.name === "string") {
5523+
info += describeDebugInfoFrame(entry.name, entry.env);
5524+
}
5525+
}
5526+
}
5527+
} // $FlowFixMe[incompatible-type] we bail out when we get a null
55085528

55095529
node = node.return;
55105530
} while (node);

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if (__DEV__) {
6666
return self;
6767
}
6868

69-
var ReactVersion = "18.3.0-www-modern-388a31ab";
69+
var ReactVersion = "18.3.0-www-modern-b6af9ab5";
7070

7171
var LegacyRoot = 0;
7272
var ConcurrentRoot = 1;
@@ -4965,6 +4965,11 @@ if (__DEV__) {
49654965
return "\n" + prefix + name;
49664966
}
49674967
}
4968+
function describeDebugInfoFrame(name, env) {
4969+
return describeBuiltInComponentFrame(
4970+
name + (env ? " (" + env + ")" : "")
4971+
);
4972+
}
49684973
var reentry = false;
49694974
var componentFrameCache;
49704975

@@ -5269,7 +5274,22 @@ if (__DEV__) {
52695274
var node = workInProgress;
52705275

52715276
do {
5272-
info += describeFiber(node); // $FlowFixMe[incompatible-type] we bail out when we get a null
5277+
info += describeFiber(node);
5278+
5279+
if (true) {
5280+
// Add any Server Component stack frames in reverse order.
5281+
var debugInfo = node._debugInfo;
5282+
5283+
if (debugInfo) {
5284+
for (var i = debugInfo.length - 1; i >= 0; i--) {
5285+
var entry = debugInfo[i];
5286+
5287+
if (typeof entry.name === "string") {
5288+
info += describeDebugInfoFrame(entry.name, entry.env);
5289+
}
5290+
}
5291+
}
5292+
} // $FlowFixMe[incompatible-type] we bail out when we get a null
52735293

52745294
node = node.return;
52755295
} while (node);

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3433,6 +3433,11 @@ if (__DEV__) {
34333433
return "\n" + prefix + name;
34343434
}
34353435
}
3436+
function describeDebugInfoFrame(name, env) {
3437+
return describeBuiltInComponentFrame(
3438+
name + (env ? " (" + env + ")" : "")
3439+
);
3440+
}
34363441
var reentry = false;
34373442
var componentFrameCache;
34383443

@@ -3737,7 +3742,22 @@ if (__DEV__) {
37373742
var node = workInProgress;
37383743

37393744
do {
3740-
info += describeFiber(node); // $FlowFixMe[incompatible-type] we bail out when we get a null
3745+
info += describeFiber(node);
3746+
3747+
if (true) {
3748+
// Add any Server Component stack frames in reverse order.
3749+
var debugInfo = node._debugInfo;
3750+
3751+
if (debugInfo) {
3752+
for (var i = debugInfo.length - 1; i >= 0; i--) {
3753+
var entry = debugInfo[i];
3754+
3755+
if (typeof entry.name === "string") {
3756+
info += describeDebugInfoFrame(entry.name, entry.env);
3757+
}
3758+
}
3759+
}
3760+
} // $FlowFixMe[incompatible-type] we bail out when we get a null
37413761

37423762
node = node.return;
37433763
} while (node);
@@ -35940,7 +35960,7 @@ if (__DEV__) {
3594035960
return root;
3594135961
}
3594235962

35943-
var ReactVersion = "18.3.0-www-classic-ba863f98";
35963+
var ReactVersion = "18.3.0-www-classic-afaf7494";
3594435964

3594535965
function createPortal$1(
3594635966
children,

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3023,6 +3023,11 @@ if (__DEV__) {
30233023
return "\n" + prefix + name;
30243024
}
30253025
}
3026+
function describeDebugInfoFrame(name, env) {
3027+
return describeBuiltInComponentFrame(
3028+
name + (env ? " (" + env + ")" : "")
3029+
);
3030+
}
30263031
var reentry = false;
30273032
var componentFrameCache;
30283033

@@ -3327,7 +3332,22 @@ if (__DEV__) {
33273332
var node = workInProgress;
33283333

33293334
do {
3330-
info += describeFiber(node); // $FlowFixMe[incompatible-type] we bail out when we get a null
3335+
info += describeFiber(node);
3336+
3337+
if (true) {
3338+
// Add any Server Component stack frames in reverse order.
3339+
var debugInfo = node._debugInfo;
3340+
3341+
if (debugInfo) {
3342+
for (var i = debugInfo.length - 1; i >= 0; i--) {
3343+
var entry = debugInfo[i];
3344+
3345+
if (typeof entry.name === "string") {
3346+
info += describeDebugInfoFrame(entry.name, entry.env);
3347+
}
3348+
}
3349+
}
3350+
} // $FlowFixMe[incompatible-type] we bail out when we get a null
33313351

33323352
node = node.return;
33333353
} while (node);
@@ -35776,7 +35796,7 @@ if (__DEV__) {
3577635796
return root;
3577735797
}
3577835798

35779-
var ReactVersion = "18.3.0-www-modern-fbeafe0c";
35799+
var ReactVersion = "18.3.0-www-modern-537964e0";
3578035800

3578135801
function createPortal$1(
3578235802
children,

compiled/facebook-www/ReactDOM-profiling.modern.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17457,7 +17457,7 @@ Internals.Events = [
1745717457
var devToolsConfig$jscomp$inline_1863 = {
1745817458
findFiberByHostInstance: getClosestInstanceFromNode,
1745917459
bundleType: 0,
17460-
version: "18.3.0-www-modern-388a31ab",
17460+
version: "18.3.0-www-modern-b6af9ab5",
1746117461
rendererPackageName: "react-dom"
1746217462
};
1746317463
(function (internals) {
@@ -17502,7 +17502,7 @@ var devToolsConfig$jscomp$inline_1863 = {
1750217502
scheduleRoot: null,
1750317503
setRefreshHandler: null,
1750417504
getCurrentFiber: null,
17505-
reconcilerVersion: "18.3.0-www-modern-388a31ab"
17505+
reconcilerVersion: "18.3.0-www-modern-b6af9ab5"
1750617506
});
1750717507
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
1750817508
exports.createPortal = function (children, container) {
@@ -17760,7 +17760,7 @@ exports.useFormState = function (action, initialState, permalink) {
1776017760
exports.useFormStatus = function () {
1776117761
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
1776217762
};
17763-
exports.version = "18.3.0-www-modern-388a31ab";
17763+
exports.version = "18.3.0-www-modern-b6af9ab5";
1776417764
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1776517765
"function" ===
1776617766
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3570,6 +3570,11 @@ if (__DEV__) {
35703570
return "\n" + prefix + name;
35713571
}
35723572
}
3573+
function describeDebugInfoFrame(name, env) {
3574+
return describeBuiltInComponentFrame(
3575+
name + (env ? " (" + env + ")" : "")
3576+
);
3577+
}
35733578
var reentry = false;
35743579
var componentFrameCache;
35753580

@@ -3874,7 +3879,22 @@ if (__DEV__) {
38743879
var node = workInProgress;
38753880

38763881
do {
3877-
info += describeFiber(node); // $FlowFixMe[incompatible-type] we bail out when we get a null
3882+
info += describeFiber(node);
3883+
3884+
if (true) {
3885+
// Add any Server Component stack frames in reverse order.
3886+
var debugInfo = node._debugInfo;
3887+
3888+
if (debugInfo) {
3889+
for (var i = debugInfo.length - 1; i >= 0; i--) {
3890+
var entry = debugInfo[i];
3891+
3892+
if (typeof entry.name === "string") {
3893+
info += describeDebugInfoFrame(entry.name, entry.env);
3894+
}
3895+
}
3896+
}
3897+
} // $FlowFixMe[incompatible-type] we bail out when we get a null
38783898

38793899
node = node.return;
38803900
} while (node);
@@ -36564,7 +36584,7 @@ if (__DEV__) {
3656436584
return root;
3656536585
}
3656636586

36567-
var ReactVersion = "18.3.0-www-classic-523eda18";
36587+
var ReactVersion = "18.3.0-www-classic-59a8d1a0";
3656836588

3656936589
function createPortal$1(
3657036590
children,

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3160,6 +3160,11 @@ if (__DEV__) {
31603160
return "\n" + prefix + name;
31613161
}
31623162
}
3163+
function describeDebugInfoFrame(name, env) {
3164+
return describeBuiltInComponentFrame(
3165+
name + (env ? " (" + env + ")" : "")
3166+
);
3167+
}
31633168
var reentry = false;
31643169
var componentFrameCache;
31653170

@@ -3464,7 +3469,22 @@ if (__DEV__) {
34643469
var node = workInProgress;
34653470

34663471
do {
3467-
info += describeFiber(node); // $FlowFixMe[incompatible-type] we bail out when we get a null
3472+
info += describeFiber(node);
3473+
3474+
if (true) {
3475+
// Add any Server Component stack frames in reverse order.
3476+
var debugInfo = node._debugInfo;
3477+
3478+
if (debugInfo) {
3479+
for (var i = debugInfo.length - 1; i >= 0; i--) {
3480+
var entry = debugInfo[i];
3481+
3482+
if (typeof entry.name === "string") {
3483+
info += describeDebugInfoFrame(entry.name, entry.env);
3484+
}
3485+
}
3486+
}
3487+
} // $FlowFixMe[incompatible-type] we bail out when we get a null
34683488

34693489
node = node.return;
34703490
} while (node);
@@ -36400,7 +36420,7 @@ if (__DEV__) {
3640036420
return root;
3640136421
}
3640236422

36403-
var ReactVersion = "18.3.0-www-modern-d6778e7a";
36423+
var ReactVersion = "18.3.0-www-modern-e0cecec0";
3640436424

3640536425
function createPortal$1(
3640636426
children,

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4130,6 +4130,11 @@ if (__DEV__) {
41304130
return "\n" + prefix + name;
41314131
}
41324132
}
4133+
function describeDebugInfoFrame(name, env) {
4134+
return describeBuiltInComponentFrame(
4135+
name + (env ? " (" + env + ")" : "")
4136+
);
4137+
}
41334138
var reentry = false;
41344139
var componentFrameCache;
41354140

@@ -4434,7 +4439,22 @@ if (__DEV__) {
44344439
var node = workInProgress;
44354440

44364441
do {
4437-
info += describeFiber(node); // $FlowFixMe[incompatible-type] we bail out when we get a null
4442+
info += describeFiber(node);
4443+
4444+
if (true) {
4445+
// Add any Server Component stack frames in reverse order.
4446+
var debugInfo = node._debugInfo;
4447+
4448+
if (debugInfo) {
4449+
for (var i = debugInfo.length - 1; i >= 0; i--) {
4450+
var entry = debugInfo[i];
4451+
4452+
if (typeof entry.name === "string") {
4453+
info += describeDebugInfoFrame(entry.name, entry.env);
4454+
}
4455+
}
4456+
}
4457+
} // $FlowFixMe[incompatible-type] we bail out when we get a null
44384458

44394459
node = node.return;
44404460
} while (node);
@@ -26077,7 +26097,7 @@ if (__DEV__) {
2607726097
return root;
2607826098
}
2607926099

26080-
var ReactVersion = "18.3.0-www-classic-671761c6";
26100+
var ReactVersion = "18.3.0-www-classic-1fba16eb";
2608126101

2608226102
// Might add PROFILE later.
2608326103

0 commit comments

Comments
 (0)