Skip to content

Commit 2b0bca0

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 commit 8fb0233.
1 parent 86ff191 commit 2b0bca0

File tree

9 files changed

+80
-17
lines changed

9 files changed

+80
-17
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

+24-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c84520e2b9d33ee51d806026be234a8a>>
10+
* @generated SignedSource<<20ec57c573e0a0a7a0d1a3309fa44b1b>>
1111
*/
1212

1313
"use strict";
@@ -4112,6 +4112,12 @@ if (__DEV__) {
41124112
return describeComponentFrame(name, ownerName);
41134113
}
41144114
}
4115+
function describeDebugInfoFrame(name, env) {
4116+
return describeBuiltInComponentFrame(
4117+
name + (env ? " (" + env + ")" : ""),
4118+
null
4119+
);
4120+
}
41154121

41164122
{
41174123
var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map;
@@ -4190,7 +4196,22 @@ if (__DEV__) {
41904196
var node = workInProgress;
41914197

41924198
do {
4193-
info += describeFiber(node); // $FlowFixMe[incompatible-type] we bail out when we get a null
4199+
info += describeFiber(node);
4200+
4201+
if (true) {
4202+
// Add any Server Component stack frames in reverse order.
4203+
var debugInfo = node._debugInfo;
4204+
4205+
if (debugInfo) {
4206+
for (var i = debugInfo.length - 1; i >= 0; i--) {
4207+
var entry = debugInfo[i];
4208+
4209+
if (typeof entry.name === "string") {
4210+
info += describeDebugInfoFrame(entry.name, entry.env);
4211+
}
4212+
}
4213+
}
4214+
} // $FlowFixMe[incompatible-type] we bail out when we get a null
41944215

41954216
node = node.return;
41964217
} while (node);
@@ -25707,7 +25728,7 @@ if (__DEV__) {
2570725728
return root;
2570825729
}
2570925730

25710-
var ReactVersion = "18.3.0-canary-66c834640-20240223";
25731+
var ReactVersion = "18.3.0-canary-8fb0233a8-20240223";
2571125732

2571225733
// Might add PROFILE later.
2571325734

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9171,7 +9171,7 @@ var devToolsConfig$jscomp$inline_1014 = {
91719171
throw Error("TestRenderer does not support findFiberByHostInstance()");
91729172
},
91739173
bundleType: 0,
9174-
version: "18.3.0-canary-66c834640-20240223",
9174+
version: "18.3.0-canary-8fb0233a8-20240223",
91759175
rendererPackageName: "react-test-renderer"
91769176
};
91779177
var internals$jscomp$inline_1195 = {
@@ -9202,7 +9202,7 @@ var internals$jscomp$inline_1195 = {
92029202
scheduleRoot: null,
92039203
setRefreshHandler: null,
92049204
getCurrentFiber: null,
9205-
reconcilerVersion: "18.3.0-canary-66c834640-20240223"
9205+
reconcilerVersion: "18.3.0-canary-8fb0233a8-20240223"
92069206
};
92079207
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
92089208
var hook$jscomp$inline_1196 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9599,7 +9599,7 @@ var devToolsConfig$jscomp$inline_1056 = {
95999599
throw Error("TestRenderer does not support findFiberByHostInstance()");
96009600
},
96019601
bundleType: 0,
9602-
version: "18.3.0-canary-66c834640-20240223",
9602+
version: "18.3.0-canary-8fb0233a8-20240223",
96039603
rendererPackageName: "react-test-renderer"
96049604
};
96059605
var internals$jscomp$inline_1236 = {
@@ -9630,7 +9630,7 @@ var internals$jscomp$inline_1236 = {
96309630
scheduleRoot: null,
96319631
setRefreshHandler: null,
96329632
getCurrentFiber: null,
9633-
reconcilerVersion: "18.3.0-canary-66c834640-20240223"
9633+
reconcilerVersion: "18.3.0-canary-8fb0233a8-20240223"
96349634
};
96359635
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
96369636
var hook$jscomp$inline_1237 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (__DEV__) {
2626
}
2727
var dynamicFlags = require("ReactNativeInternalFeatureFlags");
2828

29-
var ReactVersion = "18.3.0-canary-66c834640-20240223";
29+
var ReactVersion = "18.3.0-canary-8fb0233a8-20240223";
3030

3131
// ATTENTION
3232
// When adding new symbols to this file,

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,4 @@ exports.useSyncExternalStore = function (
600600
exports.useTransition = function () {
601601
return ReactCurrentDispatcher.current.useTransition();
602602
};
603-
exports.version = "18.3.0-canary-66c834640-20240223";
603+
exports.version = "18.3.0-canary-8fb0233a8-20240223";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ exports.useSyncExternalStore = function (
596596
exports.useTransition = function () {
597597
return ReactCurrentDispatcher.current.useTransition();
598598
};
599-
exports.version = "18.3.0-canary-66c834640-20240223";
599+
exports.version = "18.3.0-canary-8fb0233a8-20240223";
600600
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
601601
"function" ===
602602
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
66c8346401d271588e4c400921c5dab5478fc623
1+
8fb0233a845974b4b1049e54b6c25dc54d6dd173

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js

+24-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<4c526192e135ce4617cc964ef360f7e3>>
10+
* @generated SignedSource<<0fa268fef623a046bc40195fb725492a>>
1111
*/
1212

1313
"use strict";
@@ -7757,6 +7757,12 @@ to return true:wantsResponderID| |
77577757
return describeComponentFrame(name, ownerName);
77587758
}
77597759
}
7760+
function describeDebugInfoFrame(name, env) {
7761+
return describeBuiltInComponentFrame(
7762+
name + (env ? " (" + env + ")" : ""),
7763+
null
7764+
);
7765+
}
77607766
var reentry = false;
77617767
var componentFrameCache;
77627768

@@ -8088,7 +8094,22 @@ to return true:wantsResponderID| |
80888094
var node = workInProgress;
80898095

80908096
do {
8091-
info += describeFiber(node); // $FlowFixMe[incompatible-type] we bail out when we get a null
8097+
info += describeFiber(node);
8098+
8099+
if (true) {
8100+
// Add any Server Component stack frames in reverse order.
8101+
var debugInfo = node._debugInfo;
8102+
8103+
if (debugInfo) {
8104+
for (var i = debugInfo.length - 1; i >= 0; i--) {
8105+
var entry = debugInfo[i];
8106+
8107+
if (typeof entry.name === "string") {
8108+
info += describeDebugInfoFrame(entry.name, entry.env);
8109+
}
8110+
}
8111+
}
8112+
} // $FlowFixMe[incompatible-type] we bail out when we get a null
80928113

80938114
node = node.return;
80948115
} while (node);
@@ -28018,7 +28039,7 @@ to return true:wantsResponderID| |
2801828039
return root;
2801928040
}
2802028041

28021-
var ReactVersion = "18.3.0-canary-0435735f";
28042+
var ReactVersion = "18.3.0-canary-868fc9ad";
2802228043

2802328044
function createPortal$1(
2802428045
children,

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js

+24-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<2b24b949db80030833f17449b6904d8c>>
10+
* @generated SignedSource<<5be82410d05ff93f97b00ace398de099>>
1111
*/
1212

1313
"use strict";
@@ -8028,6 +8028,12 @@ to return true:wantsResponderID| |
80288028
return describeComponentFrame(name, ownerName);
80298029
}
80308030
}
8031+
function describeDebugInfoFrame(name, env) {
8032+
return describeBuiltInComponentFrame(
8033+
name + (env ? " (" + env + ")" : ""),
8034+
null
8035+
);
8036+
}
80318037
var reentry = false;
80328038
var componentFrameCache;
80338039

@@ -8359,7 +8365,22 @@ to return true:wantsResponderID| |
83598365
var node = workInProgress;
83608366

83618367
do {
8362-
info += describeFiber(node); // $FlowFixMe[incompatible-type] we bail out when we get a null
8368+
info += describeFiber(node);
8369+
8370+
if (true) {
8371+
// Add any Server Component stack frames in reverse order.
8372+
var debugInfo = node._debugInfo;
8373+
8374+
if (debugInfo) {
8375+
for (var i = debugInfo.length - 1; i >= 0; i--) {
8376+
var entry = debugInfo[i];
8377+
8378+
if (typeof entry.name === "string") {
8379+
info += describeDebugInfoFrame(entry.name, entry.env);
8380+
}
8381+
}
8382+
}
8383+
} // $FlowFixMe[incompatible-type] we bail out when we get a null
83638384

83648385
node = node.return;
83658386
} while (node);
@@ -28458,7 +28479,7 @@ to return true:wantsResponderID| |
2845828479
return root;
2845928480
}
2846028481

28461-
var ReactVersion = "18.3.0-canary-a4796866";
28482+
var ReactVersion = "18.3.0-canary-0c89aec8";
2846228483

2846328484
function createPortal$1(
2846428485
children,

0 commit comments

Comments
 (0)