Include regular stack trace in serialized errors from Fizz (#28684)

We previously only included the component stack.

Cleaned up the fields in Fizz server that wasn't using consistent hidden
classes in dev vs prod.

Added a prefix to errors serialized from server rendering. It can be a
bit confusing to see where this error came from otherwise since it
didn't come from elsewhere on the client. It's really kind of confusing
with other recoverable errors that happen on the client too.

DiffTrain build for commit https://github.com/facebook/react/commit/b9149cc6e6442389accf1f7c34a77ba2e6e52b5e.
This commit is contained in:
sebmarkbage
2024-03-30 15:13:30 +00:00
parent e4f3fc345c
commit acb6876e03
10 changed files with 64 additions and 40 deletions
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9224411efbfa8776e575f8317a5cebc6>>
* @generated SignedSource<<4c8833d67d5c40def402e9b24fc93313>>
*/
"use strict";
@@ -15825,7 +15825,7 @@ if (__DEV__) {
// get an update and we'll never be able to hydrate the final content. Let's just try the
// client side render instead.
var digest;
var message, stack;
var message, stack, componentStack;
{
var _getSuspenseInstanceF =
@@ -15834,6 +15834,7 @@ if (__DEV__) {
digest = _getSuspenseInstanceF.digest;
message = _getSuspenseInstanceF.message;
stack = _getSuspenseInstanceF.stack;
componentStack = _getSuspenseInstanceF.componentStack;
}
var capturedValue = null; // TODO: Figure out a better signal than encoding a magic digest value.
@@ -15847,13 +15848,18 @@ if (__DEV__) {
} else {
error = new Error(
"The server could not finish this Suspense boundary, likely " +
"due to an error during server rendering. Switched to " +
"client rendering."
"due to an error during server rendering. " +
"Switched to client rendering."
);
}
} // Replace the stack with the server stack
error.stack = stack || "";
error.digest = digest;
capturedValue = createCapturedValueFromError(error, digest, stack);
capturedValue = createCapturedValueFromError(
error,
digest,
componentStack
);
}
return retrySuspenseComponentWithoutHydrating(
@@ -26832,7 +26838,7 @@ if (__DEV__) {
return root;
}
var ReactVersion = "19.0.0-canary-74c595da";
var ReactVersion = "19.0.0-canary-90c44db1";
// Might add PROFILE later.
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<389fe4c4dd5a3dc2a002349defa47aea>>
* @generated SignedSource<<7ea0ba771a3dafe13783264b14f1cffd>>
*/
"use strict";
@@ -4462,6 +4462,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
(nextProps = Error(
"The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering."
)),
(nextProps.stack = ""),
(nextProps.digest = JSCompiler_temp),
(JSCompiler_temp = createCapturedValueFromError(
nextProps,
@@ -9219,7 +9220,7 @@ var devToolsConfig$jscomp$inline_1002 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-canary-dd31caf0",
version: "19.0.0-canary-0ee8586e",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1190 = {
@@ -9250,7 +9251,7 @@ var internals$jscomp$inline_1190 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-dd31caf0"
reconcilerVersion: "19.0.0-canary-0ee8586e"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1191 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<81674d0a8c35b33e23ad87b78ab22d08>>
* @generated SignedSource<<0102d8d01b7c7efdce15387c6fa804bc>>
*/
"use strict";
@@ -4633,6 +4633,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
(nextProps = Error(
"The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering."
)),
(nextProps.stack = ""),
(nextProps.digest = JSCompiler_temp),
(JSCompiler_temp = createCapturedValueFromError(
nextProps,
@@ -9837,7 +9838,7 @@ var devToolsConfig$jscomp$inline_1086 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-canary-8fc8d975",
version: "19.0.0-canary-8b0c34a5",
rendererPackageName: "react-test-renderer"
};
(function (internals) {
@@ -9881,7 +9882,7 @@ var devToolsConfig$jscomp$inline_1086 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-8fc8d975"
reconcilerVersion: "19.0.0-canary-8b0c34a5"
});
exports._Scheduler = Scheduler;
exports.act = act;
@@ -1 +1 @@
5d4b7587da52dd81bc5c366b909c4511e2970cd1
b9149cc6e6442389accf1f7c34a77ba2e6e52b5e
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<be8f8e1152affd8740c0c745720e9e1a>>
* @generated SignedSource<<569c28c9c7718b755c53912a8e17a0bd>>
*/
"use strict";
@@ -19485,7 +19485,7 @@ to return true:wantsResponderID| |
// get an update and we'll never be able to hydrate the final content. Let's just try the
// client side render instead.
var digest;
var message, stack;
var message, stack, componentStack;
{
var _getSuspenseInstanceF =
@@ -19494,6 +19494,7 @@ to return true:wantsResponderID| |
digest = _getSuspenseInstanceF.digest;
message = _getSuspenseInstanceF.message;
stack = _getSuspenseInstanceF.stack;
componentStack = _getSuspenseInstanceF.componentStack;
}
var capturedValue = null; // TODO: Figure out a better signal than encoding a magic digest value.
@@ -19507,13 +19508,18 @@ to return true:wantsResponderID| |
} else {
error = new Error(
"The server could not finish this Suspense boundary, likely " +
"due to an error during server rendering. Switched to " +
"client rendering."
"due to an error during server rendering. " +
"Switched to client rendering."
);
}
} // Replace the stack with the server stack
error.stack = stack || "";
error.digest = digest;
capturedValue = createCapturedValueFromError(error, digest, stack);
capturedValue = createCapturedValueFromError(
error,
digest,
componentStack
);
}
return retrySuspenseComponentWithoutHydrating(
@@ -30602,7 +30608,7 @@ to return true:wantsResponderID| |
return root;
}
var ReactVersion = "19.0.0-canary-89cc0451";
var ReactVersion = "19.0.0-canary-f9a3ca70";
function createPortal$1(
children,
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<6caf0298fd44810887edd334677ec6ef>>
* @generated SignedSource<<6f0e7861f6743b3815fa3d44454d6dbd>>
*/
"use strict";
@@ -6009,6 +6009,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
(nextProps = Error(
"The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering."
)),
(nextProps.stack = ""),
(nextProps.digest = JSCompiler_temp),
(JSCompiler_temp = createCapturedValueFromError(
nextProps,
@@ -10638,7 +10639,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1104 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-canary-3aaf7c49",
version: "19.0.0-canary-1065157b",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -10681,7 +10682,7 @@ var internals$jscomp$inline_1341 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-3aaf7c49"
reconcilerVersion: "19.0.0-canary-1065157b"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1342 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<7eba5ed56d62fd3b39e8d3ac4bd0561c>>
* @generated SignedSource<<9dbe74e43cd78023236dba5059713bf8>>
*/
"use strict";
@@ -6215,6 +6215,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
(nextProps = Error(
"The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering."
)),
(nextProps.stack = ""),
(nextProps.digest = JSCompiler_temp),
(JSCompiler_temp = createCapturedValueFromError(
nextProps,
@@ -11345,7 +11346,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1186 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-canary-270b90fe",
version: "19.0.0-canary-feeb7459",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -11401,7 +11402,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-270b90fe"
reconcilerVersion: "19.0.0-canary-feeb7459"
});
exports.createPortal = function (children, containerTag) {
return createPortal$1(
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<671deef2ff146cb90557b5929b5a868f>>
* @generated SignedSource<<29c94384161e3a1a33fb8ae6d6155a35>>
*/
"use strict";
@@ -19756,7 +19756,7 @@ to return true:wantsResponderID| |
// get an update and we'll never be able to hydrate the final content. Let's just try the
// client side render instead.
var digest;
var message, stack;
var message, stack, componentStack;
{
var _getSuspenseInstanceF =
@@ -19765,6 +19765,7 @@ to return true:wantsResponderID| |
digest = _getSuspenseInstanceF.digest;
message = _getSuspenseInstanceF.message;
stack = _getSuspenseInstanceF.stack;
componentStack = _getSuspenseInstanceF.componentStack;
}
var capturedValue = null; // TODO: Figure out a better signal than encoding a magic digest value.
@@ -19778,13 +19779,18 @@ to return true:wantsResponderID| |
} else {
error = new Error(
"The server could not finish this Suspense boundary, likely " +
"due to an error during server rendering. Switched to " +
"client rendering."
"due to an error during server rendering. " +
"Switched to client rendering."
);
}
} // Replace the stack with the server stack
error.stack = stack || "";
error.digest = digest;
capturedValue = createCapturedValueFromError(error, digest, stack);
capturedValue = createCapturedValueFromError(
error,
digest,
componentStack
);
}
return retrySuspenseComponentWithoutHydrating(
@@ -31042,7 +31048,7 @@ to return true:wantsResponderID| |
return root;
}
var ReactVersion = "19.0.0-canary-5f8abb5a";
var ReactVersion = "19.0.0-canary-366999b3";
function createPortal$1(
children,
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<01cbfec88e8a21340f3c759d699dada0>>
* @generated SignedSource<<6b9cf5f3bb5fc8873d7404b36e5c3753>>
*/
"use strict";
@@ -6074,6 +6074,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
(nextProps = Error(
"The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering."
)),
(nextProps.stack = ""),
(nextProps.digest = JSCompiler_temp),
(JSCompiler_temp = createCapturedValueFromError(
nextProps,
@@ -10854,7 +10855,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1171 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "19.0.0-canary-bbd4ca50",
version: "19.0.0-canary-2d04f3bb",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -10897,7 +10898,7 @@ var internals$jscomp$inline_1422 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-bbd4ca50"
reconcilerVersion: "19.0.0-canary-2d04f3bb"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1423 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<8e1902f82cf3871cb88745e438768098>>
* @generated SignedSource<<2fd9d14d7cf1c89a35f0ee934ecc3eda>>
*/
"use strict";
@@ -6280,6 +6280,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
(nextProps = Error(
"The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering."
)),
(nextProps.stack = ""),
(nextProps.digest = JSCompiler_temp),
(JSCompiler_temp = createCapturedValueFromError(
nextProps,
@@ -11562,7 +11563,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1253 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "19.0.0-canary-0502e2a7",
version: "19.0.0-canary-7e371444",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -11618,7 +11619,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-0502e2a7"
reconcilerVersion: "19.0.0-canary-7e371444"
});
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
computeComponentStackForErrorReporting: function (reactTag) {