Skip to content

Commit 29c2ced

Browse files
committed
[Flight][Fiber] Encode owner in the error payload in dev and use it as the Error's Task (#34460)
When we report an error we typically log the owner stack of the thing that caught the error. Similarly we restore the `console.createTask` scope of the catching component when we call `reportError` or `console.error`. We also have a special case if something throws during reconciliation which uses the Server Component task as far as we got before we threw. https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactChildFiber.js#L1952-L1960 Chrome has since fixed it (on our request) that the Error constructor snapshots the Task at the time the constructor was created and logs that in `reportError`. This is a good thing since it means we get a coherent stack. Unfortunately, it means that the fake Errors that we create in Flight Client gets a snapshot of the task where they were created so when they're reported in the console they get the root Task instead of the Task of the handler of the error. Ideally we'd transfer the Task from the server and restore it. However, since we don't instrument the Error object to snapshot the owner and we can't read the native Task (if it's even enabled on the server) we don't actually have a correct snapshot to transfer for a Server Component Error. However, we can use the parent's task for where the error was observed by Flight Server and then encode that as a pseudo owner of the Error. Then we use this owner as the Task which the Error is created within. Now the client snapshots that Task which is reported by `reportError` so now we have an async stack for Server Component errors again. (Note that this owner may differ from the one observed by `captureOwnerStack` which gets the nearest Server Component from where it was caught. We could attach the owner to the Error object and use that owner when calling `onCaughtError`/`onUncaughtError`). Before: <img width="911" height="57" alt="Screenshot 2025-09-10 at 10 57 54 AM" src="https://github.com/user-attachments/assets/0446ef96-fad9-4e17-8a9a-d89c334233ec" /> After: <img width="910" height="128" alt="Screenshot 2025-09-10 at 11 06 20 AM" src="https://github.com/user-attachments/assets/b30e5892-cf40-4246-a588-0f309575439b" /> Similarly, there are Errors and warnings created by ChildFiber itself. Those execute in the scope of the general render of the parent Fiber. They used to get the scope of the nearest client component parent (e.g. div in this case) but that's the parent of the Server Component. It would be too expensive to run every level of reconciliation in its own task optimistically, so this does it only when we know that we'll throw or log an error that needs this context. Unfortunately this doesn't cover user space errors (such as if an iterable errors). Before: <img width="903" height="298" alt="Screenshot 2025-09-10 at 11 31 55 AM" src="https://github.com/user-attachments/assets/cffc94da-8c14-4d6e-9a5b-bf0833b8b762" /> After: <img width="1216" height="252" alt="Screenshot 2025-09-10 at 11 50 54 AM" src="https://github.com/user-attachments/assets/f85f93cf-ab73-4046-af3d-dd93b73b3552" /> <img width="412" height="115" alt="Screenshot 2025-09-10 at 11 52 46 AM" src="https://github.com/user-attachments/assets/a76cef7b-b162-4ecf-9b0a-68bf34afc239" /> DiffTrain build for [20e5431](20e5431)
1 parent 733b550 commit 29c2ced

24 files changed

+460
-290
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.2.0-native-fb-0e10ee90-20250912
1+
19.2.0-native-fb-20e54317-20250912

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<0f6a2ee90a33efd9df582451080627a9>>
10+
* @generated SignedSource<<28cb14c888f908445cdea620aff9b5fb>>
1111
*/
1212

1313
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
404404
exports.useFormStatus = function () {
405405
return resolveDispatcher().useHostTransitionStatus();
406406
};
407-
exports.version = "19.2.0-native-fb-0e10ee90-20250912";
407+
exports.version = "19.2.0-native-fb-20e54317-20250912";
408408
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b0a9d7b14e82d82e1909db423e868eea>>
10+
* @generated SignedSource<<b5b44f51dd9a3041f0cbc89a39a0c1c4>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-0e10ee90-20250912";
206+
exports.version = "19.2.0-native-fb-20e54317-20250912";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b0a9d7b14e82d82e1909db423e868eea>>
10+
* @generated SignedSource<<b5b44f51dd9a3041f0cbc89a39a0c1c4>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-0e10ee90-20250912";
206+
exports.version = "19.2.0-native-fb-20e54317-20250912";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<18ba6e13b142d488f7296a6dc5c9047f>>
10+
* @generated SignedSource<<1cf12a1ac34badb260c1d046d70812b4>>
1111
*/
1212

1313
/*
@@ -6287,6 +6287,16 @@ __DEV__ &&
62876287
: previousDebugInfo.concat(debugInfo));
62886288
return previousDebugInfo;
62896289
}
6290+
function getCurrentDebugTask() {
6291+
var debugInfo = currentDebugInfo;
6292+
if (null != debugInfo)
6293+
for (var i = debugInfo.length - 1; 0 <= i; i--)
6294+
if (null != debugInfo[i].name) {
6295+
var debugTask = debugInfo[i].debugTask;
6296+
if (null != debugTask) return debugTask;
6297+
}
6298+
return null;
6299+
}
62906300
function validateFragmentProps(element, fiber, returnFiber) {
62916301
for (var keys = Object.keys(element.props), i = 0; i < keys.length; i++) {
62926302
var key = keys[i];
@@ -6328,7 +6338,7 @@ __DEV__ &&
63286338
element = element.props.ref;
63296339
workInProgress.ref = void 0 !== element ? element : null;
63306340
}
6331-
function throwOnInvalidObjectType(returnFiber, newChild) {
6341+
function throwOnInvalidObjectTypeImpl(returnFiber, newChild) {
63326342
if (newChild.$$typeof === REACT_LEGACY_ELEMENT_TYPE)
63336343
throw Error(
63346344
'A React Element from an older version of React was rendered. This is not supported. It can happen if:\n- Multiple copies of the "react" package is used.\n- A library pre-bundled an old copy of "react" or "react/jsx-runtime".\n- A compiler tries to "inline" JSX instead of using the runtime.'
@@ -6342,7 +6352,15 @@ __DEV__ &&
63426352
"). If you meant to render a collection of children, use an array instead."
63436353
);
63446354
}
6345-
function warnOnFunctionType(returnFiber, invalidChild) {
6355+
function throwOnInvalidObjectType(returnFiber, newChild) {
6356+
var debugTask = getCurrentDebugTask();
6357+
null !== debugTask
6358+
? debugTask.run(
6359+
throwOnInvalidObjectTypeImpl.bind(null, returnFiber, newChild)
6360+
)
6361+
: throwOnInvalidObjectTypeImpl(returnFiber, newChild);
6362+
}
6363+
function warnOnFunctionTypeImpl(returnFiber, invalidChild) {
63466364
var parentName = getComponentNameFromFiber(returnFiber) || "Component";
63476365
ownerHasFunctionTypeWarning[parentName] ||
63486366
((ownerHasFunctionTypeWarning[parentName] = !0),
@@ -6364,7 +6382,15 @@ __DEV__ &&
63646382
parentName
63656383
));
63666384
}
6367-
function warnOnSymbolType(returnFiber, invalidChild) {
6385+
function warnOnFunctionType(returnFiber, invalidChild) {
6386+
var debugTask = getCurrentDebugTask();
6387+
null !== debugTask
6388+
? debugTask.run(
6389+
warnOnFunctionTypeImpl.bind(null, returnFiber, invalidChild)
6390+
)
6391+
: warnOnFunctionTypeImpl(returnFiber, invalidChild);
6392+
}
6393+
function warnOnSymbolTypeImpl(returnFiber, invalidChild) {
63686394
var parentName = getComponentNameFromFiber(returnFiber) || "Component";
63696395
ownerHasSymbolTypeWarning[parentName] ||
63706396
((ownerHasSymbolTypeWarning[parentName] = !0),
@@ -6381,6 +6407,14 @@ __DEV__ &&
63816407
parentName
63826408
));
63836409
}
6410+
function warnOnSymbolType(returnFiber, invalidChild) {
6411+
var debugTask = getCurrentDebugTask();
6412+
null !== debugTask
6413+
? debugTask.run(
6414+
warnOnSymbolTypeImpl.bind(null, returnFiber, invalidChild)
6415+
)
6416+
: warnOnSymbolTypeImpl(returnFiber, invalidChild);
6417+
}
63846418
function createChildReconciler(shouldTrackSideEffects) {
63856419
function deleteChild(returnFiber, childToDelete) {
63866420
if (shouldTrackSideEffects) {
@@ -29594,11 +29628,11 @@ __DEV__ &&
2959429628
};
2959529629
(function () {
2959629630
var isomorphicReactPackageVersion = React.version;
29597-
if ("19.2.0-native-fb-0e10ee90-20250912" !== isomorphicReactPackageVersion)
29631+
if ("19.2.0-native-fb-20e54317-20250912" !== isomorphicReactPackageVersion)
2959829632
throw Error(
2959929633
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2960029634
(isomorphicReactPackageVersion +
29601-
"\n - react-dom: 19.2.0-native-fb-0e10ee90-20250912\nLearn more: https://react.dev/warnings/version-mismatch")
29635+
"\n - react-dom: 19.2.0-native-fb-20e54317-20250912\nLearn more: https://react.dev/warnings/version-mismatch")
2960229636
);
2960329637
})();
2960429638
("function" === typeof Map &&
@@ -29635,10 +29669,10 @@ __DEV__ &&
2963529669
!(function () {
2963629670
var internals = {
2963729671
bundleType: 1,
29638-
version: "19.2.0-native-fb-0e10ee90-20250912",
29672+
version: "19.2.0-native-fb-20e54317-20250912",
2963929673
rendererPackageName: "react-dom",
2964029674
currentDispatcherRef: ReactSharedInternals,
29641-
reconcilerVersion: "19.2.0-native-fb-0e10ee90-20250912"
29675+
reconcilerVersion: "19.2.0-native-fb-20e54317-20250912"
2964229676
};
2964329677
internals.overrideHookState = overrideHookState;
2964429678
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -29787,5 +29821,5 @@ __DEV__ &&
2978729821
listenToAllSupportedEvents(container);
2978829822
return new ReactDOMHydrationRoot(initialChildren);
2978929823
};
29790-
exports.version = "19.2.0-native-fb-0e10ee90-20250912";
29824+
exports.version = "19.2.0-native-fb-20e54317-20250912";
2979129825
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<230cc31bff672c7533986f41b2507963>>
10+
* @generated SignedSource<<5cdd71807a3cbd6c1c203605c76d530c>>
1111
*/
1212

1313
/*
@@ -3546,7 +3546,7 @@ function coerceRef(workInProgress, element) {
35463546
element = element.props.ref;
35473547
workInProgress.ref = void 0 !== element ? element : null;
35483548
}
3549-
function throwOnInvalidObjectType(returnFiber, newChild) {
3549+
function throwOnInvalidObjectTypeImpl(returnFiber, newChild) {
35503550
if (newChild.$$typeof === REACT_LEGACY_ELEMENT_TYPE)
35513551
throw Error(formatProdErrorMessage(525));
35523552
returnFiber = Object.prototype.toString.call(newChild);
@@ -3759,7 +3759,7 @@ function createChildReconciler(shouldTrackSideEffects) {
37593759
readContextDuringReconciliation(returnFiber, newChild),
37603760
lanes
37613761
);
3762-
throwOnInvalidObjectType(returnFiber, newChild);
3762+
throwOnInvalidObjectTypeImpl(returnFiber, newChild);
37633763
}
37643764
return null;
37653765
}
@@ -3807,7 +3807,7 @@ function createChildReconciler(shouldTrackSideEffects) {
38073807
readContextDuringReconciliation(returnFiber, newChild),
38083808
lanes
38093809
);
3810-
throwOnInvalidObjectType(returnFiber, newChild);
3810+
throwOnInvalidObjectTypeImpl(returnFiber, newChild);
38113811
}
38123812
return null;
38133813
}
@@ -3878,7 +3878,7 @@ function createChildReconciler(shouldTrackSideEffects) {
38783878
readContextDuringReconciliation(returnFiber, newChild),
38793879
lanes
38803880
);
3881-
throwOnInvalidObjectType(returnFiber, newChild);
3881+
throwOnInvalidObjectTypeImpl(returnFiber, newChild);
38823882
}
38833883
return null;
38843884
}
@@ -4206,7 +4206,7 @@ function createChildReconciler(shouldTrackSideEffects) {
42064206
readContextDuringReconciliation(returnFiber, newChild),
42074207
lanes
42084208
);
4209-
throwOnInvalidObjectType(returnFiber, newChild);
4209+
throwOnInvalidObjectTypeImpl(returnFiber, newChild);
42104210
}
42114211
return ("string" === typeof newChild && "" !== newChild) ||
42124212
"number" === typeof newChild ||
@@ -13127,20 +13127,20 @@ function debounceScrollEnd(targetInst, nativeEvent, nativeEventTarget) {
1312713127
(nativeEventTarget[internalScrollTimer] = targetInst));
1312813128
}
1312913129
for (
13130-
var i$jscomp$inline_1651 = 0;
13131-
i$jscomp$inline_1651 < simpleEventPluginEvents.length;
13132-
i$jscomp$inline_1651++
13130+
var i$jscomp$inline_1663 = 0;
13131+
i$jscomp$inline_1663 < simpleEventPluginEvents.length;
13132+
i$jscomp$inline_1663++
1313313133
) {
13134-
var eventName$jscomp$inline_1652 =
13135-
simpleEventPluginEvents[i$jscomp$inline_1651],
13136-
domEventName$jscomp$inline_1653 =
13137-
eventName$jscomp$inline_1652.toLowerCase(),
13138-
capitalizedEvent$jscomp$inline_1654 =
13139-
eventName$jscomp$inline_1652[0].toUpperCase() +
13140-
eventName$jscomp$inline_1652.slice(1);
13134+
var eventName$jscomp$inline_1664 =
13135+
simpleEventPluginEvents[i$jscomp$inline_1663],
13136+
domEventName$jscomp$inline_1665 =
13137+
eventName$jscomp$inline_1664.toLowerCase(),
13138+
capitalizedEvent$jscomp$inline_1666 =
13139+
eventName$jscomp$inline_1664[0].toUpperCase() +
13140+
eventName$jscomp$inline_1664.slice(1);
1314113141
registerSimpleEvent(
13142-
domEventName$jscomp$inline_1653,
13143-
"on" + capitalizedEvent$jscomp$inline_1654
13142+
domEventName$jscomp$inline_1665,
13143+
"on" + capitalizedEvent$jscomp$inline_1666
1314413144
);
1314513145
}
1314613146
registerSimpleEvent(ANIMATION_END, "onAnimationEnd");
@@ -17386,16 +17386,16 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1738617386
0 === i && attemptExplicitHydrationTarget(target);
1738717387
}
1738817388
};
17389-
var isomorphicReactPackageVersion$jscomp$inline_2057 = React.version;
17389+
var isomorphicReactPackageVersion$jscomp$inline_2069 = React.version;
1739017390
if (
17391-
"19.2.0-native-fb-0e10ee90-20250912" !==
17392-
isomorphicReactPackageVersion$jscomp$inline_2057
17391+
"19.2.0-native-fb-20e54317-20250912" !==
17392+
isomorphicReactPackageVersion$jscomp$inline_2069
1739317393
)
1739417394
throw Error(
1739517395
formatProdErrorMessage(
1739617396
527,
17397-
isomorphicReactPackageVersion$jscomp$inline_2057,
17398-
"19.2.0-native-fb-0e10ee90-20250912"
17397+
isomorphicReactPackageVersion$jscomp$inline_2069,
17398+
"19.2.0-native-fb-20e54317-20250912"
1739917399
)
1740017400
);
1740117401
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17415,24 +17415,24 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1741517415
null === componentOrElement ? null : componentOrElement.stateNode;
1741617416
return componentOrElement;
1741717417
};
17418-
var internals$jscomp$inline_2630 = {
17418+
var internals$jscomp$inline_2642 = {
1741917419
bundleType: 0,
17420-
version: "19.2.0-native-fb-0e10ee90-20250912",
17420+
version: "19.2.0-native-fb-20e54317-20250912",
1742117421
rendererPackageName: "react-dom",
1742217422
currentDispatcherRef: ReactSharedInternals,
17423-
reconcilerVersion: "19.2.0-native-fb-0e10ee90-20250912"
17423+
reconcilerVersion: "19.2.0-native-fb-20e54317-20250912"
1742417424
};
1742517425
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
17426-
var hook$jscomp$inline_2631 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
17426+
var hook$jscomp$inline_2643 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
1742717427
if (
17428-
!hook$jscomp$inline_2631.isDisabled &&
17429-
hook$jscomp$inline_2631.supportsFiber
17428+
!hook$jscomp$inline_2643.isDisabled &&
17429+
hook$jscomp$inline_2643.supportsFiber
1743017430
)
1743117431
try {
17432-
(rendererID = hook$jscomp$inline_2631.inject(
17433-
internals$jscomp$inline_2630
17432+
(rendererID = hook$jscomp$inline_2643.inject(
17433+
internals$jscomp$inline_2642
1743417434
)),
17435-
(injectedHook = hook$jscomp$inline_2631);
17435+
(injectedHook = hook$jscomp$inline_2643);
1743617436
} catch (err) {}
1743717437
}
1743817438
exports.createRoot = function (container, options) {
@@ -17527,4 +17527,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1752717527
listenToAllSupportedEvents(container);
1752817528
return new ReactDOMHydrationRoot(initialChildren);
1752917529
};
17530-
exports.version = "19.2.0-native-fb-0e10ee90-20250912";
17530+
exports.version = "19.2.0-native-fb-20e54317-20250912";

0 commit comments

Comments
 (0)