Skip to content

Commit 25dfa8e

Browse files
committed
Use the Nearest Parent of an Errored Promise as its Owner (#29814)
Stacked on #29807. Conceptually the error's owner/task should ideally be captured when the Error constructor is called but neither `console.createTask` does this, nor do we override `Error` to capture our `owner`. So instead, we use the nearest parent as the owner/task of the error. This is usually the same thing when it's thrown from the same async component but not if you await a promise started from a different component/task. Before this stack the "owner" and "task" of a Lazy that errors was the nearest Fiber but if the thing erroring is a Server Component, we need to get that as the owner from the inner most part of debugInfo. To get the Task for that Server Component, we need to expose it on the ReactComponentInfo object. Unfortunately that makes the object not serializable so we need to special case this to exclude it from serialization. It gets restored again on the client. Before (Shell): <img width="813" alt="Screenshot 2024-06-06 at 5 16 20 PM" src="https://github.com/facebook/react/assets/63648/7da2d4c9-539b-494e-ba63-1abdc58ff13c"> After (App): <img width="811" alt="Screenshot 2024-06-08 at 12 29 23 AM" src="https://github.com/facebook/react/assets/63648/dbf40bd7-c24d-4200-81a6-5018bef55f6d"> DiffTrain build for [383b2a1](383b2a1)
1 parent 5ad4e79 commit 25dfa8e

36 files changed

+5447
-5416
lines changed

compiled/facebook-www/JSXDEVRuntime-dev.classic.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,13 @@ __DEV__ &&
431431
break;
432432
case 23:
433433
return "LegacyHidden";
434+
case 29:
435+
type = fiber._debugInfo;
436+
if (null != type)
437+
for (var i = type.length - 1; 0 <= i; i--)
438+
if ("string" === typeof type[i].name) return type[i].name;
439+
if (null !== fiber.return)
440+
return getComponentNameFromFiber(fiber.return);
434441
}
435442
return null;
436443
}

compiled/facebook-www/JSXDEVRuntime-dev.modern.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,13 @@ __DEV__ &&
428428
break;
429429
case 23:
430430
return "LegacyHidden";
431+
case 29:
432+
type = fiber._debugInfo;
433+
if (null != type)
434+
for (var i = type.length - 1; 0 <= i; i--)
435+
if ("string" === typeof type[i].name) return type[i].name;
436+
if (null !== fiber.return)
437+
return getComponentNameFromFiber(fiber.return);
431438
}
432439
return null;
433440
}

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
270229f0c337dc652f07ef27d2254bb922bfaa9e
1+
383b2a18456215d2d3ec46f33c0c912e84efa08f
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
270229f0c337dc652f07ef27d2254bb922bfaa9e
1+
383b2a18456215d2d3ec46f33c0c912e84efa08f

compiled/facebook-www/React-dev.classic.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,13 @@ __DEV__ &&
517517
break;
518518
case 23:
519519
return "LegacyHidden";
520+
case 29:
521+
type = fiber._debugInfo;
522+
if (null != type)
523+
for (var i = type.length - 1; 0 <= i; i--)
524+
if ("string" === typeof type[i].name) return type[i].name;
525+
if (null !== fiber.return)
526+
return getComponentNameFromFiber(fiber.return);
520527
}
521528
return null;
522529
}
@@ -1980,7 +1987,7 @@ __DEV__ &&
19801987
exports.useTransition = function () {
19811988
return resolveDispatcher().useTransition();
19821989
};
1983-
exports.version = "19.0.0-www-classic-270229f0c3-20240611";
1990+
exports.version = "19.0.0-www-classic-383b2a1845-20240611";
19841991
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19851992
"function" ===
19861993
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,13 @@ __DEV__ &&
514514
break;
515515
case 23:
516516
return "LegacyHidden";
517+
case 29:
518+
type = fiber._debugInfo;
519+
if (null != type)
520+
for (var i = type.length - 1; 0 <= i; i--)
521+
if ("string" === typeof type[i].name) return type[i].name;
522+
if (null !== fiber.return)
523+
return getComponentNameFromFiber(fiber.return);
517524
}
518525
return null;
519526
}
@@ -1960,7 +1967,7 @@ __DEV__ &&
19601967
exports.useTransition = function () {
19611968
return resolveDispatcher().useTransition();
19621969
};
1963-
exports.version = "19.0.0-www-modern-270229f0c3-20240611";
1970+
exports.version = "19.0.0-www-modern-383b2a1845-20240611";
19641971
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19651972
"function" ===
19661973
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,4 @@ exports.useSyncExternalStore = function (
665665
exports.useTransition = function () {
666666
return ReactSharedInternals.H.useTransition();
667667
};
668-
exports.version = "19.0.0-www-classic-270229f0c3-20240611";
668+
exports.version = "19.0.0-www-classic-383b2a1845-20240611";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,4 @@ exports.useSyncExternalStore = function (
665665
exports.useTransition = function () {
666666
return ReactSharedInternals.H.useTransition();
667667
};
668-
exports.version = "19.0.0-www-modern-270229f0c3-20240611";
668+
exports.version = "19.0.0-www-modern-383b2a1845-20240611";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ exports.useSyncExternalStore = function (
669669
exports.useTransition = function () {
670670
return ReactSharedInternals.H.useTransition();
671671
};
672-
exports.version = "19.0.0-www-classic-270229f0c3-20240611";
672+
exports.version = "19.0.0-www-classic-383b2a1845-20240611";
673673
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
674674
"function" ===
675675
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ exports.useSyncExternalStore = function (
669669
exports.useTransition = function () {
670670
return ReactSharedInternals.H.useTransition();
671671
};
672-
exports.version = "19.0.0-www-modern-270229f0c3-20240611";
672+
exports.version = "19.0.0-www-modern-383b2a1845-20240611";
673673
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
674674
"function" ===
675675
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)