[Flight] Also don't cut off type and key (#31209)
Sebastian Markbåge committed
Oct 13, 2024 at 12:57 UTC
cd22717c274061fd7dc13cd6eaff10e6a3946508
2 files changed
+13
-4
packages/react-client/src/ReactFlightClient.js
+2
-4
@@ -1364,10 +1364,8 @@ function parseModelString(
1364
// happened.
1365
Object.defineProperty(parentObject, key, {
1366
get: function () {
1367
- // We intentionally don't throw an error object here because it looks better
1368
- // without the stack in the console which isn't useful anyway.
1369
- // eslint-disable-next-line no-throw-literal
1370
- throw (
1367
+ // TODO: We should ideally throw here to indicate a difference.
1368
+ return (
1369
'This object has been omitted by React in the console log ' +
1370
'to avoid sending too much data from the server. Try logging smaller ' +
1371
'or more specific objects.'
packages/react-server/src/ReactFlightServer.js
+11
@@ -3465,7 +3465,18 @@ function renderConsoleValue(
3465
if (element._owner != null) {
3466
outlineComponentInfo(request, element._owner);
3467
}
3468
+ if (typeof element.type === 'object' && element.type !== null) {
3469
+ // If the type is an object it can get cut off which shouldn't happen here.
3470
+ doNotLimit.add(element.type);
3471
+ }
3472
+ if (typeof element.key === 'object' && element.key !== null) {
3473
+ // This should never happen but just in case.
3474
+ doNotLimit.add(element.key);
3475
+ }
3476
doNotLimit.add(element.props);
3477
+ if (element._owner !== null) {
3478
+ doNotLimit.add(element._owner);
3479
+ }
3480
3481
if (enableOwnerStacks) {
3482
let debugStack: null | ReactStackTrace = null;