Skip to content

Commit 6af8405

Browse files
committed
[Fiber] Use Owner/JSX Stack When Appending Stacks to Console (#29206)
This one should be fully behind the `enableOwnerStacks` flag. Instead of printing the parent Component stack all the way to the root, this now prints the owner stack of every JSX callsite. It also includes intermediate callsites between the Component and the JSX call so it has potentially more frames. Mainly it provides the line number of the JSX callsite. In terms of the number of components is a subset of the parent component stack so it's less information in that regard. This is usually better since it's more focused on components that might affect the output but if it's contextual based on rendering it's still good to have parent stack. Therefore, I still use the parent stack when printing DOM nesting warnings but I plan on switching that format to a diff view format instead (Next.js already reformats the parent stack like this). __Follow ups__ - Server Components show up in the owner stack for client logs but logs done by Server Components don't yet get their owner stack printed as they're replayed. They're also not yet printed in the server logs of the RSC server. - Server Component stack frames are formatted as the server and added to the end but this might be a different format than the browser. E.g. if server is running V8 and browser is running JSC or vice versa. Ideally we can reformat them in terms of the client formatting. - This doesn't yet update Fizz or DevTools. Those will be follow ups. Fizz still prints parent stacks in the server side logs. The stacks added to user space `console.error` calls by DevTools still get the parent stacks instead. - It also doesn't yet expose these to user space so there's no way to get them inside `onCaughtError` for example or inside a custom `console.error` override. - In another follow up I'll use `console.createTask` instead and completely remove these stacks if it's available. DiffTrain build for [d6cfa0f](d6cfa0f)
1 parent 4374cb6 commit 6af8405

29 files changed

Lines changed: 1061 additions & 466 deletions

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,10 @@ var didWarnAboutKeySpread = {};
11841184
*/
11851185

11861186
function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
1187+
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
1188+
}
1189+
1190+
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) {
11871191
{
11881192
if (!isValidElementType(type)) {
11891193
// This is an invalid element type.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,10 @@ var didWarnAboutKeySpread = {};
11871187
*/
11881188

11891189
function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
1190+
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
1191+
}
1192+
1193+
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) {
11901194
{
11911195
if (!isValidElementType(type)) {
11921196
// This is an invalid element type.

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ee5c19493086fdeb32057e16d1e3414370242307
1+
d6cfa0f295f4c8b366af15fd20c84e27cdd1fab7

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if (
2222
) {
2323
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2424
}
25-
var ReactVersion = '19.0.0-www-classic-f3d67148';
25+
var ReactVersion = '19.0.0-www-classic-5a597884';
2626

2727
// Re-export dynamic flags from the www version.
2828
var dynamicFeatureFlags = require('ReactFeatureFlags');
@@ -1448,13 +1448,13 @@ function ReactElement(type, key, _ref, self, source, owner, props, debugStack, d
14481448
function jsxProdSignatureRunningInDevWithDynamicChildren(type, config, maybeKey, source, self) {
14491449
{
14501450
var isStaticChildren = false;
1451-
return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self);
1451+
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
14521452
}
14531453
}
14541454
function jsxProdSignatureRunningInDevWithStaticChildren(type, config, maybeKey, source, self) {
14551455
{
14561456
var isStaticChildren = true;
1457-
return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self);
1457+
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
14581458
}
14591459
}
14601460
var didWarnAboutKeySpread = {};
@@ -1466,6 +1466,10 @@ var didWarnAboutKeySpread = {};
14661466
*/
14671467

14681468
function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
1469+
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
1470+
}
1471+
1472+
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) {
14691473
{
14701474
if (!isValidElementType(type)) {
14711475
// This is an invalid element type.
@@ -1639,6 +1643,7 @@ function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
16391643
* See https://reactjs.org/docs/react-api.html#createelement
16401644
*/
16411645

1646+
16421647
function createElement(type, config, children) {
16431648
{
16441649
if (!isValidElementType(type)) {
@@ -2731,7 +2736,9 @@ function forwardRef(render) {
27312736
// This kind of inner function is not used elsewhere so the side effect is okay.
27322737

27332738
if (!render.name && !render.displayName) {
2734-
render.displayName = name;
2739+
Object.defineProperty(render, 'name', {
2740+
value: name
2741+
});
27352742
}
27362743
}
27372744
});
@@ -2771,7 +2778,9 @@ function memo(type, compare) {
27712778
// This kind of inner function is not used elsewhere so the side effect is okay.
27722779

27732780
if (!type.name && !type.displayName) {
2774-
type.displayName = name;
2781+
Object.defineProperty(type, 'name', {
2782+
value: name
2783+
});
27752784
}
27762785
}
27772786
});

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if (
2222
) {
2323
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2424
}
25-
var ReactVersion = '19.0.0-www-modern-7638663c';
25+
var ReactVersion = '19.0.0-www-modern-c9630b74';
2626

2727
// Re-export dynamic flags from the www version.
2828
var dynamicFeatureFlags = require('ReactFeatureFlags');
@@ -1451,13 +1451,13 @@ function ReactElement(type, key, _ref, self, source, owner, props, debugStack, d
14511451
function jsxProdSignatureRunningInDevWithDynamicChildren(type, config, maybeKey, source, self) {
14521452
{
14531453
var isStaticChildren = false;
1454-
return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self);
1454+
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
14551455
}
14561456
}
14571457
function jsxProdSignatureRunningInDevWithStaticChildren(type, config, maybeKey, source, self) {
14581458
{
14591459
var isStaticChildren = true;
1460-
return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self);
1460+
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
14611461
}
14621462
}
14631463
var didWarnAboutKeySpread = {};
@@ -1469,6 +1469,10 @@ var didWarnAboutKeySpread = {};
14691469
*/
14701470

14711471
function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
1472+
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
1473+
}
1474+
1475+
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) {
14721476
{
14731477
if (!isValidElementType(type)) {
14741478
// This is an invalid element type.
@@ -1642,6 +1646,7 @@ function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
16421646
* See https://reactjs.org/docs/react-api.html#createelement
16431647
*/
16441648

1649+
16451650
function createElement(type, config, children) {
16461651
{
16471652
if (!isValidElementType(type)) {
@@ -2734,7 +2739,9 @@ function forwardRef(render) {
27342739
// This kind of inner function is not used elsewhere so the side effect is okay.
27352740

27362741
if (!render.name && !render.displayName) {
2737-
render.displayName = name;
2742+
Object.defineProperty(render, 'name', {
2743+
value: name
2744+
});
27382745
}
27392746
}
27402747
});
@@ -2774,7 +2781,9 @@ function memo(type, compare) {
27742781
// This kind of inner function is not used elsewhere so the side effect is okay.
27752782

27762783
if (!type.name && !type.displayName) {
2777-
type.displayName = name;
2784+
Object.defineProperty(type, 'name', {
2785+
value: name
2786+
});
27782787
}
27792788
}
27802789
});

0 commit comments

Comments
 (0)