Skip to content

Commit 1c54b5d

Browse files
committed
Remove top stack frame from getCurrentStack (#30306)
The full stack is the current execution stack (`new Error().stack`) + the current owner stack (`React.captureOwnerStack()`). The idea with the top frame was that when we append it to console.error we'd include both since otherwise the true reason would be obscured behind the little `>` to expand. So we'd just put both stack front and center. By adding this into getCurrentStack it was easy to use the same filtering. I never implemented in Fizz or Flight though. However, with the public API `React.captureOwnerStack()` it's not necessary to include the current stack since you already have it and you'd have filtering capabilities in user space too. Since I'm removing the component stacks from React itself we no longer need this. It's expected that maybe RDT or framework polyfill would include this same technique though. DiffTrain build for commit 433068e.
1 parent fc516e2 commit 1c54b5d

16 files changed

+73
-75
lines changed

compiled-rn/VERSION_NATIVE_FB

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.0.0-native-fb-a5cc797b88-20240711
1+
19.0.0-native-fb-433068ee-20240711

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b05d30bdaf64de7f584d29654e5ef1da>>
10+
* @generated SignedSource<<333ee47fc63e94412bc1786f307125aa>>
1111
*/
1212

1313
"use strict";
@@ -141,7 +141,7 @@ __DEV__ &&
141141
_key++
142142
)
143143
args[_key - 1] = arguments[_key];
144-
printWarning("warn", format, args, Error("react-stack-top-frame"));
144+
printWarning("warn", format, args);
145145
}
146146
function error$jscomp$0(format) {
147147
for (
@@ -152,13 +152,13 @@ __DEV__ &&
152152
_key2++
153153
)
154154
args[_key2 - 1] = arguments[_key2];
155-
printWarning("error", format, args, Error("react-stack-top-frame"));
155+
printWarning("error", format, args);
156156
}
157-
function printWarning(level, format, args, currentStack) {
158-
ReactSharedInternals.getCurrentStack &&
159-
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
160-
"" !== currentStack &&
161-
((format += "%s"), (args = args.concat([currentStack]))));
157+
function printWarning(level, format, args) {
158+
if (ReactSharedInternals.getCurrentStack) {
159+
var stack = ReactSharedInternals.getCurrentStack();
160+
"" !== stack && ((format += "%s"), (args = args.concat([stack])));
161+
}
162162
args.unshift(format);
163163
Function.prototype.apply.call(console[level], console, args);
164164
}
@@ -15169,14 +15169,14 @@ __DEV__ &&
1516915169
scheduleRoot: scheduleRoot,
1517015170
setRefreshHandler: setRefreshHandler,
1517115171
getCurrentFiber: getCurrentFiberForDevTools,
15172-
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
15172+
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
1517315173
});
1517415174
})({
1517515175
findFiberByHostInstance: function () {
1517615176
throw Error("TestRenderer does not support findFiberByHostInstance()");
1517715177
},
1517815178
bundleType: 1,
15179-
version: "19.0.0-native-fb-a5cc797b88-20240711",
15179+
version: "19.0.0-native-fb-433068ee-20240711",
1518015180
rendererPackageName: "react-test-renderer"
1518115181
});
1518215182
exports._Scheduler = Scheduler;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<3a2415433bcca86523904edffb77200a>>
10+
* @generated SignedSource<<770de2d7f078e68aa256a0a52d0270ef>>
1111
*/
1212

1313
"use strict";
@@ -9384,7 +9384,7 @@ var devToolsConfig$jscomp$inline_1053 = {
93849384
throw Error("TestRenderer does not support findFiberByHostInstance()");
93859385
},
93869386
bundleType: 0,
9387-
version: "19.0.0-native-fb-a5cc797b88-20240711",
9387+
version: "19.0.0-native-fb-433068ee-20240711",
93889388
rendererPackageName: "react-test-renderer"
93899389
};
93909390
var internals$jscomp$inline_1240 = {
@@ -9415,7 +9415,7 @@ var internals$jscomp$inline_1240 = {
94159415
scheduleRoot: null,
94169416
setRefreshHandler: null,
94179417
getCurrentFiber: null,
9418-
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
9418+
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
94199419
};
94209420
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
94219421
var hook$jscomp$inline_1241 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<21c3fe0c07bcc7c87001795650f2598b>>
10+
* @generated SignedSource<<95a5b427ae173a570593f02efac9bcc1>>
1111
*/
1212

1313
"use strict";
@@ -10004,7 +10004,7 @@ var devToolsConfig$jscomp$inline_1136 = {
1000410004
throw Error("TestRenderer does not support findFiberByHostInstance()");
1000510005
},
1000610006
bundleType: 0,
10007-
version: "19.0.0-native-fb-a5cc797b88-20240711",
10007+
version: "19.0.0-native-fb-433068ee-20240711",
1000810008
rendererPackageName: "react-test-renderer"
1000910009
};
1001010010
(function (internals) {
@@ -10048,7 +10048,7 @@ var devToolsConfig$jscomp$inline_1136 = {
1004810048
scheduleRoot: null,
1004910049
setRefreshHandler: null,
1005010050
getCurrentFiber: null,
10051-
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
10051+
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
1005210052
});
1005310053
exports._Scheduler = Scheduler;
1005410054
exports.act = act;

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

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

1313
"use strict";
@@ -23,9 +23,8 @@ __DEV__ &&
2323
)
2424
args[_key2 - 1] = arguments[_key2];
2525
_len2 = format;
26-
_key2 = Error("react-stack-top-frame");
2726
ReactSharedInternals.getCurrentStack &&
28-
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
27+
((_key2 = ReactSharedInternals.getCurrentStack()),
2928
"" !== _key2 && ((_len2 += "%s"), (args = args.concat([_key2]))));
3029
args.unshift(_len2);
3130
Function.prototype.apply.call(console.error, console, args);

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<7ad8e11753e71d86731728e561f85039>>
10+
* @generated SignedSource<<8de8fd144d056267c7877ddd4494da73>>
1111
*/
1212

1313
"use strict";
@@ -23,9 +23,8 @@ __DEV__ &&
2323
)
2424
args[_key2 - 1] = arguments[_key2];
2525
_len2 = format;
26-
_key2 = Error("react-stack-top-frame");
2726
ReactSharedInternals.getCurrentStack &&
28-
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
27+
((_key2 = ReactSharedInternals.getCurrentStack()),
2928
"" !== _key2 && ((_len2 += "%s"), (args = args.concat([_key2]))));
3029
args.unshift(_len2);
3130
Function.prototype.apply.call(console.error, console, args);

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<9bf9089d14c921e559cf75a8baf3b007>>
10+
* @generated SignedSource<<34ae957fdb21cf0094807e7ed74a96b2>>
1111
*/
1212

1313
"use strict";
@@ -41,7 +41,7 @@ __DEV__ &&
4141
_key++
4242
)
4343
args[_key - 1] = arguments[_key];
44-
printWarning("warn", format, args, Error("react-stack-top-frame"));
44+
printWarning("warn", format, args);
4545
}
4646
function error$jscomp$0(format) {
4747
for (
@@ -52,13 +52,13 @@ __DEV__ &&
5252
_key2++
5353
)
5454
args[_key2 - 1] = arguments[_key2];
55-
printWarning("error", format, args, Error("react-stack-top-frame"));
55+
printWarning("error", format, args);
5656
}
57-
function printWarning(level, format, args, currentStack) {
58-
ReactSharedInternals.getCurrentStack &&
59-
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
60-
"" !== currentStack &&
61-
((format += "%s"), (args = args.concat([currentStack]))));
57+
function printWarning(level, format, args) {
58+
if (ReactSharedInternals.getCurrentStack) {
59+
var stack = ReactSharedInternals.getCurrentStack();
60+
"" !== stack && ((format += "%s"), (args = args.concat([stack])));
61+
}
6262
args.unshift(format);
6363
Function.prototype.apply.call(console[level], console, args);
6464
}
@@ -1748,7 +1748,7 @@ __DEV__ &&
17481748
exports.useTransition = function () {
17491749
return resolveDispatcher().useTransition();
17501750
};
1751-
exports.version = "19.0.0-native-fb-a5cc797b88-20240711";
1751+
exports.version = "19.0.0-native-fb-433068ee-20240711";
17521752
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
17531753
"function" ===
17541754
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<044edcae7a5eba00592e83c733d86903>>
10+
* @generated SignedSource<<81d462de814b7397d95fe0efc953f039>>
1111
*/
1212

1313
"use strict";
@@ -604,4 +604,4 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.0.0-native-fb-a5cc797b88-20240711";
607+
exports.version = "19.0.0-native-fb-433068ee-20240711";

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<16f7644bca35eb02a5a5b29cc4849da8>>
10+
* @generated SignedSource<<796537f38aedde210ea37ac64ce0f740>>
1111
*/
1212

1313
"use strict";
@@ -608,7 +608,7 @@ exports.useSyncExternalStore = function (
608608
exports.useTransition = function () {
609609
return ReactSharedInternals.H.useTransition();
610610
};
611-
exports.version = "19.0.0-native-fb-a5cc797b88-20240711";
611+
exports.version = "19.0.0-native-fb-433068ee-20240711";
612612
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
613613
"function" ===
614614
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a5cc797b8801dfe58c7a34c99a9fa60c6c9c8274
1+
433068eece2071a96de98b60f99ce6a9121a629c

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<7d835c87e5f5af6809615cdd2871b34d>>
10+
* @generated SignedSource<<9e809495c8f8c2620055e72bf5cdddf0>>
1111
*/
1212

1313
"use strict";
@@ -139,7 +139,7 @@ __DEV__ &&
139139
_key++
140140
)
141141
args[_key - 1] = arguments[_key];
142-
printWarning("warn", format, args, Error("react-stack-top-frame"));
142+
printWarning("warn", format, args);
143143
}
144144
}
145145
function error$jscomp$0(format) {
@@ -152,14 +152,14 @@ __DEV__ &&
152152
_key2++
153153
)
154154
args[_key2 - 1] = arguments[_key2];
155-
printWarning("error", format, args, Error("react-stack-top-frame"));
155+
printWarning("error", format, args);
156156
}
157157
}
158-
function printWarning(level, format, args, currentStack) {
159-
ReactSharedInternals.getCurrentStack &&
160-
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
161-
"" !== currentStack &&
162-
((format += "%s"), (args = args.concat([currentStack]))));
158+
function printWarning(level, format, args) {
159+
if (ReactSharedInternals.getCurrentStack) {
160+
var stack = ReactSharedInternals.getCurrentStack();
161+
"" !== stack && ((format += "%s"), (args = args.concat([stack])));
162+
}
163163
args.unshift(format);
164164
Function.prototype.apply.call(console[level], console, args);
165165
}
@@ -16821,12 +16821,12 @@ __DEV__ &&
1682116821
scheduleRoot: scheduleRoot,
1682216822
setRefreshHandler: setRefreshHandler,
1682316823
getCurrentFiber: getCurrentFiberForDevTools,
16824-
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
16824+
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
1682516825
});
1682616826
})({
1682716827
findFiberByHostInstance: getInstanceFromNode,
1682816828
bundleType: 1,
16829-
version: "19.0.0-native-fb-a5cc797b88-20240711",
16829+
version: "19.0.0-native-fb-433068ee-20240711",
1683016830
rendererPackageName: "react-native-renderer",
1683116831
rendererConfig: {
1683216832
getInspectorDataForInstance: getInspectorDataForInstance,

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b8313605600caf1669eb49a8439f380c>>
10+
* @generated SignedSource<<8d30459760ba9fc43b543d7399b934e5>>
1111
*/
1212

1313
"use strict";
@@ -10632,7 +10632,7 @@ var roots = new Map(),
1063210632
devToolsConfig$jscomp$inline_1136 = {
1063310633
findFiberByHostInstance: getInstanceFromNode,
1063410634
bundleType: 0,
10635-
version: "19.0.0-native-fb-a5cc797b88-20240711",
10635+
version: "19.0.0-native-fb-433068ee-20240711",
1063610636
rendererPackageName: "react-native-renderer",
1063710637
rendererConfig: {
1063810638
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -10675,7 +10675,7 @@ var internals$jscomp$inline_1362 = {
1067510675
scheduleRoot: null,
1067610676
setRefreshHandler: null,
1067710677
getCurrentFiber: null,
10678-
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
10678+
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
1067910679
};
1068010680
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1068110681
var hook$jscomp$inline_1363 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<16348ae4e8fa87230c6e47ddc2b12f6b>>
10+
* @generated SignedSource<<fba595d10eb9d1b0871bcd3abde0f9bb>>
1111
*/
1212

1313
"use strict";
@@ -11342,7 +11342,7 @@ var roots = new Map(),
1134211342
devToolsConfig$jscomp$inline_1217 = {
1134311343
findFiberByHostInstance: getInstanceFromNode,
1134411344
bundleType: 0,
11345-
version: "19.0.0-native-fb-a5cc797b88-20240711",
11345+
version: "19.0.0-native-fb-433068ee-20240711",
1134611346
rendererPackageName: "react-native-renderer",
1134711347
rendererConfig: {
1134811348
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -11398,7 +11398,7 @@ var roots = new Map(),
1139811398
scheduleRoot: null,
1139911399
setRefreshHandler: null,
1140011400
getCurrentFiber: null,
11401-
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
11401+
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
1140211402
});
1140311403
exports.createPortal = function (children, containerTag) {
1140411404
return createPortal$1(

0 commit comments

Comments
 (0)