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 [433068e](433068e)
  • Loading branch information
sebmarkbage committed Jul 11, 2024
1 parent 2a5d4d4 commit f91895d
Show file tree
Hide file tree
Showing 39 changed files with 171 additions and 175 deletions.
9 changes: 4 additions & 5 deletions compiled/facebook-www/JSXDEVRuntime-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ __DEV__ &&
)
args[_key2 - 1] = arguments[_key2];
_len2 = format;
_key2 = Error("react-stack-top-frame");
var ReactSharedInternals =
_key2 =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != ReactSharedInternals &&
ReactSharedInternals.getCurrentStack &&
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
null != _key2 &&
_key2.getCurrentStack &&
((_key2 = _key2.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), args.push(_key2)));
args.unshift(_len2);
args.unshift(!1);
Expand Down
9 changes: 4 additions & 5 deletions compiled/facebook-www/JSXDEVRuntime-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ __DEV__ &&
)
args[_key2 - 1] = arguments[_key2];
_len2 = format;
_key2 = Error("react-stack-top-frame");
var ReactSharedInternals =
_key2 =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != ReactSharedInternals &&
ReactSharedInternals.getCurrentStack &&
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
null != _key2 &&
_key2.getCurrentStack &&
((_key2 = _key2.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), args.push(_key2)));
args.unshift(_len2);
args.unshift(!1);
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
af28f480e8e74ce71bb33259b61fef8a5a228f74
433068eece2071a96de98b60f99ce6a9121a629c
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
af28f480e8e74ce71bb33259b61fef8a5a228f74
433068eece2071a96de98b60f99ce6a9121a629c
12 changes: 6 additions & 6 deletions compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
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,15 +52,15 @@ __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) {
function printWarning(level, format, args) {
level =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != level &&
level.getCurrentStack &&
((currentStack = level.getCurrentStack(currentStack)),
"" !== currentStack && ((format += "%s"), args.push(currentStack)));
((level = level.getCurrentStack()),
"" !== level && ((format += "%s"), args.push(level)));
args.unshift(format);
args.unshift(!1);
warningWWW.apply(null, args);
Expand Down Expand Up @@ -1998,7 +1998,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.0.0-www-classic-af28f480-20240711";
exports.version = "19.0.0-www-classic-433068ee-20240711";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
12 changes: 6 additions & 6 deletions compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
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,15 +52,15 @@ __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) {
function printWarning(level, format, args) {
level =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != level &&
level.getCurrentStack &&
((currentStack = level.getCurrentStack(currentStack)),
"" !== currentStack && ((format += "%s"), args.push(currentStack)));
((level = level.getCurrentStack()),
"" !== level && ((format += "%s"), args.push(level)));
args.unshift(format);
args.unshift(!1);
warningWWW.apply(null, args);
Expand Down Expand Up @@ -1978,7 +1978,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.0.0-www-modern-af28f480-20240711";
exports.version = "19.0.0-www-modern-433068ee-20240711";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-classic-af28f480-20240711";
exports.version = "19.0.0-www-classic-433068ee-20240711";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-modern-af28f480-20240711";
exports.version = "19.0.0-www-modern-433068ee-20240711";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-classic-af28f480-20240711";
exports.version = "19.0.0-www-classic-433068ee-20240711";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-modern-af28f480-20240711";
exports.version = "19.0.0-www-modern-433068ee-20240711";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
14 changes: 7 additions & 7 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,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 @@ -174,16 +174,16 @@ __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) {
function printWarning(level, format, args) {
level =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != level &&
level.getCurrentStack &&
((currentStack = level.getCurrentStack(currentStack)),
"" !== currentStack && ((format += "%s"), args.push(currentStack)));
((level = level.getCurrentStack()),
"" !== level && ((format += "%s"), args.push(level)));
args.unshift(format);
args.unshift(!1);
warningWWW.apply(null, args);
Expand Down Expand Up @@ -17021,14 +17021,14 @@ __DEV__ &&
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
getCurrentFiber: getCurrentFiberForDevTools,
reconcilerVersion: "19.0.0-www-classic-af28f480-20240711"
reconcilerVersion: "19.0.0-www-classic-433068ee-20240711"
});
})({
findFiberByHostInstance: function () {
return null;
},
bundleType: 1,
version: "19.0.0-www-classic-af28f480-20240711",
version: "19.0.0-www-classic-433068ee-20240711",
rendererPackageName: "react-art"
});
var ClippingRectangle = TYPES.CLIPPING_RECTANGLE,
Expand Down
14 changes: 7 additions & 7 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,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 @@ -174,16 +174,16 @@ __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) {
function printWarning(level, format, args) {
level =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != level &&
level.getCurrentStack &&
((currentStack = level.getCurrentStack(currentStack)),
"" !== currentStack && ((format += "%s"), args.push(currentStack)));
((level = level.getCurrentStack()),
"" !== level && ((format += "%s"), args.push(level)));
args.unshift(format);
args.unshift(!1);
warningWWW.apply(null, args);
Expand Down Expand Up @@ -16432,14 +16432,14 @@ __DEV__ &&
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
getCurrentFiber: getCurrentFiberForDevTools,
reconcilerVersion: "19.0.0-www-modern-af28f480-20240711"
reconcilerVersion: "19.0.0-www-modern-433068ee-20240711"
});
})({
findFiberByHostInstance: function () {
return null;
},
bundleType: 1,
version: "19.0.0-www-modern-af28f480-20240711",
version: "19.0.0-www-modern-433068ee-20240711",
rendererPackageName: "react-art"
});
var ClippingRectangle = TYPES.CLIPPING_RECTANGLE,
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactART-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -10753,7 +10753,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "19.0.0-www-classic-af28f480-20240711",
version: "19.0.0-www-classic-433068ee-20240711",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1386 = {
Expand Down Expand Up @@ -10784,7 +10784,7 @@ var internals$jscomp$inline_1386 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-af28f480-20240711"
reconcilerVersion: "19.0.0-www-classic-433068ee-20240711"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1387 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactART-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -10202,7 +10202,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "19.0.0-www-modern-af28f480-20240711",
version: "19.0.0-www-modern-433068ee-20240711",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1372 = {
Expand Down Expand Up @@ -10233,7 +10233,7 @@ var internals$jscomp$inline_1372 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-af28f480-20240711"
reconcilerVersion: "19.0.0-www-modern-433068ee-20240711"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1373 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
9 changes: 4 additions & 5 deletions compiled/facebook-www/ReactCacheOld-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ __DEV__ &&
)
args[_key2 - 1] = arguments[_key2];
_len2 = format;
_key2 = Error("react-stack-top-frame");
var ReactSharedInternals =
_key2 =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != ReactSharedInternals &&
ReactSharedInternals.getCurrentStack &&
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
null != _key2 &&
_key2.getCurrentStack &&
((_key2 = _key2.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), args.push(_key2)));
args.unshift(_len2);
args.unshift(!1);
Expand Down
9 changes: 4 additions & 5 deletions compiled/facebook-www/ReactCacheOld-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ __DEV__ &&
)
args[_key2 - 1] = arguments[_key2];
_len2 = format;
_key2 = Error("react-stack-top-frame");
var ReactSharedInternals =
_key2 =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != ReactSharedInternals &&
ReactSharedInternals.getCurrentStack &&
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
null != _key2 &&
_key2.getCurrentStack &&
((_key2 = _key2.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), args.push(_key2)));
args.unshift(_len2);
args.unshift(!1);
Expand Down
20 changes: 10 additions & 10 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,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 @@ -151,16 +151,16 @@ __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) {
function printWarning(level, format, args) {
level =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != level &&
level.getCurrentStack &&
((currentStack = level.getCurrentStack(currentStack)),
"" !== currentStack && ((format += "%s"), args.push(currentStack)));
((level = level.getCurrentStack()),
"" !== level && ((format += "%s"), args.push(level)));
args.unshift(format);
args.unshift(!1);
warningWWW.apply(null, args);
Expand Down Expand Up @@ -27570,11 +27570,11 @@ __DEV__ &&
: flushSyncErrorInBuildsThatSupportLegacyMode;
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-www-classic-af28f480-20240711" !== isomorphicReactPackageVersion)
if ("19.0.0-www-classic-433068ee-20240711" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.0.0-www-classic-af28f480-20240711\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.0.0-www-classic-433068ee-20240711\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -27640,12 +27640,12 @@ __DEV__ &&
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
getCurrentFiber: getCurrentFiberForDevTools,
reconcilerVersion: "19.0.0-www-classic-af28f480-20240711"
reconcilerVersion: "19.0.0-www-classic-433068ee-20240711"
});
})({
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 1,
version: "19.0.0-www-classic-af28f480-20240711",
version: "19.0.0-www-classic-433068ee-20240711",
rendererPackageName: "react-dom"
}) &&
canUseDOM &&
Expand Down Expand Up @@ -28288,7 +28288,7 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.0.0-www-classic-af28f480-20240711";
exports.version = "19.0.0-www-classic-433068ee-20240711";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Loading

0 comments on commit f91895d

Please sign in to comment.