Skip to content

Commit

Permalink
Remove top stack frame from getCurrentStack (#30306)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebmarkbage committed Jul 11, 2024
1 parent fc516e2 commit 1c54b5d
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 75 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.0.0-native-fb-a5cc797b88-20240711
19.0.0-native-fb-433068ee-20240711
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b05d30bdaf64de7f584d29654e5ef1da>>
* @generated SignedSource<<333ee47fc63e94412bc1786f307125aa>>
*/

"use strict";
Expand Down Expand Up @@ -141,7 +141,7 @@ __DEV__ &&
_key++
)
args[_key - 1] = arguments[_key];
printWarning("warn", format, args, Error("react-stack-top-frame"));
printWarning("warn", format, args);
}
function error$jscomp$0(format) {
for (
Expand All @@ -152,13 +152,13 @@ __DEV__ &&
_key2++
)
args[_key2 - 1] = arguments[_key2];
printWarning("error", format, args, Error("react-stack-top-frame"));
printWarning("error", format, args);
}
function printWarning(level, format, args, currentStack) {
ReactSharedInternals.getCurrentStack &&
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
"" !== currentStack &&
((format += "%s"), (args = args.concat([currentStack]))));
function printWarning(level, format, args) {
if (ReactSharedInternals.getCurrentStack) {
var stack = ReactSharedInternals.getCurrentStack();
"" !== stack && ((format += "%s"), (args = args.concat([stack])));
}
args.unshift(format);
Function.prototype.apply.call(console[level], console, args);
}
Expand Down Expand Up @@ -15169,14 +15169,14 @@ __DEV__ &&
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
getCurrentFiber: getCurrentFiberForDevTools,
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
});
})({
findFiberByHostInstance: function () {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 1,
version: "19.0.0-native-fb-a5cc797b88-20240711",
version: "19.0.0-native-fb-433068ee-20240711",
rendererPackageName: "react-test-renderer"
});
exports._Scheduler = Scheduler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<3a2415433bcca86523904edffb77200a>>
* @generated SignedSource<<770de2d7f078e68aa256a0a52d0270ef>>
*/

"use strict";
Expand Down Expand Up @@ -9384,7 +9384,7 @@ var devToolsConfig$jscomp$inline_1053 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-native-fb-a5cc797b88-20240711",
version: "19.0.0-native-fb-433068ee-20240711",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1240 = {
Expand Down Expand Up @@ -9415,7 +9415,7 @@ var internals$jscomp$inline_1240 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1241 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<21c3fe0c07bcc7c87001795650f2598b>>
* @generated SignedSource<<95a5b427ae173a570593f02efac9bcc1>>
*/

"use strict";
Expand Down Expand Up @@ -10004,7 +10004,7 @@ var devToolsConfig$jscomp$inline_1136 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-native-fb-a5cc797b88-20240711",
version: "19.0.0-native-fb-433068ee-20240711",
rendererPackageName: "react-test-renderer"
};
(function (internals) {
Expand Down Expand Up @@ -10048,7 +10048,7 @@ var devToolsConfig$jscomp$inline_1136 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
});
exports._Scheduler = Scheduler;
exports.act = act;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2e4bfe3b6770b799c0ba60be06b0baca>>
* @generated SignedSource<<a4c1d0f50a5efb1181a4421da7347531>>
*/

"use strict";
Expand All @@ -23,9 +23,8 @@ __DEV__ &&
)
args[_key2 - 1] = arguments[_key2];
_len2 = format;
_key2 = Error("react-stack-top-frame");
ReactSharedInternals.getCurrentStack &&
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
((_key2 = ReactSharedInternals.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), (args = args.concat([_key2]))));
args.unshift(_len2);
Function.prototype.apply.call(console.error, console, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<7ad8e11753e71d86731728e561f85039>>
* @generated SignedSource<<8de8fd144d056267c7877ddd4494da73>>
*/

"use strict";
Expand All @@ -23,9 +23,8 @@ __DEV__ &&
)
args[_key2 - 1] = arguments[_key2];
_len2 = format;
_key2 = Error("react-stack-top-frame");
ReactSharedInternals.getCurrentStack &&
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
((_key2 = ReactSharedInternals.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), (args = args.concat([_key2]))));
args.unshift(_len2);
Function.prototype.apply.call(console.error, console, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9bf9089d14c921e559cf75a8baf3b007>>
* @generated SignedSource<<34ae957fdb21cf0094807e7ed74a96b2>>
*/

"use strict";
Expand Down Expand Up @@ -41,7 +41,7 @@ __DEV__ &&
_key++
)
args[_key - 1] = arguments[_key];
printWarning("warn", format, args, Error("react-stack-top-frame"));
printWarning("warn", format, args);
}
function error$jscomp$0(format) {
for (
Expand All @@ -52,13 +52,13 @@ __DEV__ &&
_key2++
)
args[_key2 - 1] = arguments[_key2];
printWarning("error", format, args, Error("react-stack-top-frame"));
printWarning("error", format, args);
}
function printWarning(level, format, args, currentStack) {
ReactSharedInternals.getCurrentStack &&
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
"" !== currentStack &&
((format += "%s"), (args = args.concat([currentStack]))));
function printWarning(level, format, args) {
if (ReactSharedInternals.getCurrentStack) {
var stack = ReactSharedInternals.getCurrentStack();
"" !== stack && ((format += "%s"), (args = args.concat([stack])));
}
args.unshift(format);
Function.prototype.apply.call(console[level], console, args);
}
Expand Down Expand Up @@ -1748,7 +1748,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.0.0-native-fb-a5cc797b88-20240711";
exports.version = "19.0.0-native-fb-433068ee-20240711";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<044edcae7a5eba00592e83c733d86903>>
* @generated SignedSource<<81d462de814b7397d95fe0efc953f039>>
*/

"use strict";
Expand Down Expand Up @@ -604,4 +604,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-native-fb-a5cc797b88-20240711";
exports.version = "19.0.0-native-fb-433068ee-20240711";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<16f7644bca35eb02a5a5b29cc4849da8>>
* @generated SignedSource<<796537f38aedde210ea37ac64ce0f740>>
*/

"use strict";
Expand Down Expand Up @@ -608,7 +608,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-native-fb-a5cc797b88-20240711";
exports.version = "19.0.0-native-fb-433068ee-20240711";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a5cc797b8801dfe58c7a34c99a9fa60c6c9c8274
433068eece2071a96de98b60f99ce6a9121a629c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<7d835c87e5f5af6809615cdd2871b34d>>
* @generated SignedSource<<9e809495c8f8c2620055e72bf5cdddf0>>
*/

"use strict";
Expand Down Expand Up @@ -139,7 +139,7 @@ __DEV__ &&
_key++
)
args[_key - 1] = arguments[_key];
printWarning("warn", format, args, Error("react-stack-top-frame"));
printWarning("warn", format, args);
}
}
function error$jscomp$0(format) {
Expand All @@ -152,14 +152,14 @@ __DEV__ &&
_key2++
)
args[_key2 - 1] = arguments[_key2];
printWarning("error", format, args, Error("react-stack-top-frame"));
printWarning("error", format, args);
}
}
function printWarning(level, format, args, currentStack) {
ReactSharedInternals.getCurrentStack &&
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
"" !== currentStack &&
((format += "%s"), (args = args.concat([currentStack]))));
function printWarning(level, format, args) {
if (ReactSharedInternals.getCurrentStack) {
var stack = ReactSharedInternals.getCurrentStack();
"" !== stack && ((format += "%s"), (args = args.concat([stack])));
}
args.unshift(format);
Function.prototype.apply.call(console[level], console, args);
}
Expand Down Expand Up @@ -16821,12 +16821,12 @@ __DEV__ &&
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
getCurrentFiber: getCurrentFiberForDevTools,
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
});
})({
findFiberByHostInstance: getInstanceFromNode,
bundleType: 1,
version: "19.0.0-native-fb-a5cc797b88-20240711",
version: "19.0.0-native-fb-433068ee-20240711",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b8313605600caf1669eb49a8439f380c>>
* @generated SignedSource<<8d30459760ba9fc43b543d7399b934e5>>
*/

"use strict";
Expand Down Expand Up @@ -10632,7 +10632,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1136 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-native-fb-a5cc797b88-20240711",
version: "19.0.0-native-fb-433068ee-20240711",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -10675,7 +10675,7 @@ var internals$jscomp$inline_1362 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1363 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<16348ae4e8fa87230c6e47ddc2b12f6b>>
* @generated SignedSource<<fba595d10eb9d1b0871bcd3abde0f9bb>>
*/

"use strict";
Expand Down Expand Up @@ -11342,7 +11342,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1217 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-native-fb-a5cc797b88-20240711",
version: "19.0.0-native-fb-433068ee-20240711",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -11398,7 +11398,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-a5cc797b88-20240711"
reconcilerVersion: "19.0.0-native-fb-433068ee-20240711"
});
exports.createPortal = function (children, containerTag) {
return createPortal$1(
Expand Down
Loading

0 comments on commit 1c54b5d

Please sign in to comment.