Skip to content

Commit

Permalink
Override the getCurrentStack temporarily while printing uncaught erro…
Browse files Browse the repository at this point in the history
…rs (#30309)

This is just a follow up to #30300.

I forgot the uncaught branch.

DiffTrain build for commit 29552c7.
  • Loading branch information
sebmarkbage committed Jul 10, 2024
1 parent 1d800df commit 106b53a
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 69 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-fe9828954a-20240710
19.0.0-native-fb-29552c7907-20240710
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9cef70fc774ae45a7e3850789b3cb38f>>
* @generated SignedSource<<f766cda8f6a41676186e7ea897b38f29>>
*/

"use strict";
Expand Down Expand Up @@ -5498,14 +5498,24 @@ __DEV__ &&
}
function defaultOnUncaughtError(error, errorInfo) {
reportGlobalError(error);
console.warn(
"%s\n\n%s\n%s",
componentName
? "An error occurred in the <" + componentName + "> component."
: "An error occurred in one of your React components.",
"Consider adding an error boundary to your tree to customize error handling behavior.\nVisit https://react.dev/link/error-boundaries to learn more about error boundaries.",
null != errorInfo.componentStack ? errorInfo.componentStack : ""
);
error = componentName
? "An error occurred in the <" + componentName + "> component."
: "An error occurred in one of your React components.";
var prevGetCurrentStack = ReactSharedInternals.getCurrentStack,
componentStack =
null != errorInfo.componentStack ? errorInfo.componentStack : "";
ReactSharedInternals.getCurrentStack = function () {
return componentStack;
};
try {
warn(
"%s\n\n%s\n",
error,
"Consider adding an error boundary to your tree to customize error handling behavior.\nVisit https://react.dev/link/error-boundaries to learn more about error boundaries."
);
} finally {
ReactSharedInternals.getCurrentStack = prevGetCurrentStack;
}
}
function defaultOnCaughtError(error$1, errorInfo) {
var componentNameMessage = componentName
Expand Down Expand Up @@ -15159,14 +15169,14 @@ __DEV__ &&
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
getCurrentFiber: getCurrentFiberForDevTools,
reconcilerVersion: "19.0.0-native-fb-fe9828954a-20240710"
reconcilerVersion: "19.0.0-native-fb-29552c7907-20240710"
});
})({
findFiberByHostInstance: function () {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 1,
version: "19.0.0-native-fb-fe9828954a-20240710",
version: "19.0.0-native-fb-29552c7907-20240710",
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<<40cb55a2c17e388258d1238f01fa536e>>
* @generated SignedSource<<0354488ea1b30b1146f64e808964461b>>
*/

"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-fe9828954a-20240710",
version: "19.0.0-native-fb-29552c7907-20240710",
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-fe9828954a-20240710"
reconcilerVersion: "19.0.0-native-fb-29552c7907-20240710"
};
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<<e98e00def07c1371021bb79653377e82>>
* @generated SignedSource<<59693bd0a7873ee89c09692e6c0a697d>>
*/

"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-fe9828954a-20240710",
version: "19.0.0-native-fb-29552c7907-20240710",
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-fe9828954a-20240710"
reconcilerVersion: "19.0.0-native-fb-29552c7907-20240710"
});
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<<e982d75c61c17cbc3d14cab1c9ad15e8>>
* @generated SignedSource<<786cfef00e2f9aaad9c106c8db4f1293>>
*/

"use strict";
Expand Down Expand Up @@ -1748,7 +1748,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.0.0-native-fb-fe9828954a-20240710";
exports.version = "19.0.0-native-fb-29552c7907-20240710";
"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<<2f82adcf7d438c0b2588e872ad5b60a8>>
* @generated SignedSource<<2354cadbb30771bcd284f32d5f5227ba>>
*/

"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-fe9828954a-20240710";
exports.version = "19.0.0-native-fb-29552c7907-20240710";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<fcd04ff4f2d392cbe8aa60a3f5262fce>>
* @generated SignedSource<<ddfbd55a0d4a2dd8e33a5d7fe0caf163>>
*/

"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-fe9828954a-20240710";
exports.version = "19.0.0-native-fb-29552c7907-20240710";
"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 @@
fe9828954adcc51aa2bd21fe53d969a44dd3c9d2
29552c7907230222acd3f2c586784d24f9da6200
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<8bbbf707b5c0fdbafff9a599d611e079>>
* @generated SignedSource<<99aa42ccbe839946fd66c4bb0a15e2ac>>
*/

"use strict";
Expand Down Expand Up @@ -6497,6 +6497,27 @@ __DEV__ &&
}
return baseProps;
}
function defaultOnUncaughtError(error, errorInfo) {
reportGlobalError(error);
error = componentName
? "An error occurred in the <" + componentName + "> component."
: "An error occurred in one of your React components.";
var prevGetCurrentStack = ReactSharedInternals.getCurrentStack,
componentStack =
null != errorInfo.componentStack ? errorInfo.componentStack : "";
ReactSharedInternals.getCurrentStack = function () {
return componentStack;
};
try {
warn(
"%s\n\n%s\n",
error,
"Consider adding an error boundary to your tree to customize error handling behavior.\nVisit https://react.dev/link/error-boundaries to learn more about error boundaries."
);
} finally {
ReactSharedInternals.getCurrentStack = prevGetCurrentStack;
}
}
function defaultOnCaughtError(error$1, errorInfo) {
var componentNameMessage = componentName
? "The above error occurred in the <" + componentName + "> component."
Expand Down Expand Up @@ -14209,16 +14230,7 @@ __DEV__ &&
error: error,
componentStack:
null != errorInfo.componentStack ? errorInfo.componentStack : ""
}) &&
(reportGlobalError(error),
console.warn(
"%s\n\n%s\n%s",
componentName
? "An error occurred in the <" + componentName + "> component."
: "An error occurred in one of your React components.",
"Consider adding an error boundary to your tree to customize error handling behavior.\nVisit https://react.dev/link/error-boundaries to learn more about error boundaries.",
null != errorInfo.componentStack ? errorInfo.componentStack : ""
));
}) && defaultOnUncaughtError(error, errorInfo);
}
function nativeOnCaughtError(error, errorInfo) {
!1 !==
Expand Down Expand Up @@ -16809,12 +16821,12 @@ __DEV__ &&
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
getCurrentFiber: getCurrentFiberForDevTools,
reconcilerVersion: "19.0.0-native-fb-fe9828954a-20240710"
reconcilerVersion: "19.0.0-native-fb-29552c7907-20240710"
});
})({
findFiberByHostInstance: getInstanceFromNode,
bundleType: 1,
version: "19.0.0-native-fb-fe9828954a-20240710",
version: "19.0.0-native-fb-29552c7907-20240710",
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<<c77fee587e5dac8c50f6592780bb8ef0>>
* @generated SignedSource<<47f2cff113a0e8735d34f879855fc544>>
*/

"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-fe9828954a-20240710",
version: "19.0.0-native-fb-29552c7907-20240710",
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-fe9828954a-20240710"
reconcilerVersion: "19.0.0-native-fb-29552c7907-20240710"
};
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<<ee62cdcf9e7e3856c1468052944519d6>>
* @generated SignedSource<<924bfcced405a3f09fce824c3c8619ae>>
*/

"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-fe9828954a-20240710",
version: "19.0.0-native-fb-29552c7907-20240710",
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-fe9828954a-20240710"
reconcilerVersion: "19.0.0-native-fb-29552c7907-20240710"
});
exports.createPortal = function (children, containerTag) {
return createPortal$1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<8584109002f045b3c3f3a2b760460d87>>
* @generated SignedSource<<f3f3cf91f04ba94a2614315d5362e5f5>>
*/

"use strict";
Expand Down Expand Up @@ -6443,6 +6443,27 @@ __DEV__ &&
}
return baseProps;
}
function defaultOnUncaughtError(error, errorInfo) {
reportGlobalError(error);
error = componentName
? "An error occurred in the <" + componentName + "> component."
: "An error occurred in one of your React components.";
var prevGetCurrentStack = ReactSharedInternals.getCurrentStack,
componentStack =
null != errorInfo.componentStack ? errorInfo.componentStack : "";
ReactSharedInternals.getCurrentStack = function () {
return componentStack;
};
try {
warn(
"%s\n\n%s\n",
error,
"Consider adding an error boundary to your tree to customize error handling behavior.\nVisit https://react.dev/link/error-boundaries to learn more about error boundaries."
);
} finally {
ReactSharedInternals.getCurrentStack = prevGetCurrentStack;
}
}
function defaultOnCaughtError(error$1, errorInfo) {
var componentNameMessage = componentName
? "The above error occurred in the <" + componentName + "> component."
Expand Down Expand Up @@ -14338,16 +14359,7 @@ __DEV__ &&
error: error,
componentStack:
null != errorInfo.componentStack ? errorInfo.componentStack : ""
}) &&
(reportGlobalError(error),
console.warn(
"%s\n\n%s\n%s",
componentName
? "An error occurred in the <" + componentName + "> component."
: "An error occurred in one of your React components.",
"Consider adding an error boundary to your tree to customize error handling behavior.\nVisit https://react.dev/link/error-boundaries to learn more about error boundaries.",
null != errorInfo.componentStack ? errorInfo.componentStack : ""
));
}) && defaultOnUncaughtError(error, errorInfo);
}
function nativeOnCaughtError(error, errorInfo) {
!1 !==
Expand Down Expand Up @@ -16997,11 +17009,11 @@ __DEV__ &&
var emptyObject = {};
Object.freeze(emptyObject);
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-native-fb-fe9828954a-20240710" !== isomorphicReactPackageVersion)
if ("19.0.0-native-fb-29552c7907-20240710" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.0.0-native-fb-fe9828954a-20240710\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.0.0-native-fb-29552c7907-20240710\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
Expand Down Expand Up @@ -17049,12 +17061,12 @@ __DEV__ &&
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
getCurrentFiber: getCurrentFiberForDevTools,
reconcilerVersion: "19.0.0-native-fb-fe9828954a-20240710"
reconcilerVersion: "19.0.0-native-fb-29552c7907-20240710"
});
})({
findFiberByHostInstance: getInstanceFromTag,
bundleType: 1,
version: "19.0.0-native-fb-fe9828954a-20240710",
version: "19.0.0-native-fb-29552c7907-20240710",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down
Loading

0 comments on commit 106b53a

Please sign in to comment.