Skip to content

Commit 5344d07

Browse files
committed
[Fizz] Add Component Stacks to onError and onPostpone when in dev mode or during prerenders in prod mode (#27761)
Historically React would produce component stacks for dev builds only. There is a cost to tracking component stacks and given the prod builds try to optimize runtime performance these stacks were left out. More recently React added production component stacks to Fiber in because it can be immensely helpful in tracking down hard to debug production issues. Fizz was not updated to have a similar behavior. With the advent of prerendering however stacks for production in Fizz are more relevant because prerendering is not really a dev-time task. If you want the ability to reason about errors or postpones that happen during a prerender having component stacks to interrogate is helpful and these component stacks need to be available in production otherwise you are really never going to see them. (it is possible that you could do dev-mode prerenders but we don't expect this to be a common dev mode workflow) To better support the prerender use case and to make error logging in Fizz more useful the following changes have been made 1. `onPostpone` now accepts a second `postponeInfo` argument which will contain a componentStack. Postpones always originate from a component render so the stack should be consistently available. The type however will indicate the stack is optional so we can remove them in the future if we decide the overhead is the wrong tradeoff in certain cases 2. `onError` now accepts a second `errorInfo` argument which may contain a componentStack. If an error originated from a component a stack will be included in the following cases. This change entails tracking the component hierarchy in prod builds now. While this isn't cost free it is implemented in a relatively lean manner. Deferring the most expensive work (reifying the stack) until we are actually in an error pathway. In the course of implementing this change a number of simplifications were made to the code which should make the stack tracking more resilient. We no longer use a module global to curry the stack up to some handler. This was delicate because you needed to always reset it properly. We now curry the stack on the task itself. Another change made was to track the component stack on SuspenseBoundary instances so that we can provide the stack when aborting suspense boundaries to help you determine which ones were affected by an abort. DiffTrain build for commit 63310df.
1 parent 8991f3e commit 5344d07

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25476,7 +25476,7 @@ if (__DEV__) {
2547625476
return root;
2547725477
}
2547825478

25479-
var ReactVersion = "18.3.0-canary-493610f29-20231212";
25479+
var ReactVersion = "18.3.0-canary-63310df2b-20231215";
2548025480

2548125481
// Might add PROFILE later.
2548225482

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9083,7 +9083,7 @@ var devToolsConfig$jscomp$inline_1033 = {
90839083
throw Error("TestRenderer does not support findFiberByHostInstance()");
90849084
},
90859085
bundleType: 0,
9086-
version: "18.3.0-canary-493610f29-20231212",
9086+
version: "18.3.0-canary-63310df2b-20231215",
90879087
rendererPackageName: "react-test-renderer"
90889088
};
90899089
var internals$jscomp$inline_1226 = {
@@ -9114,7 +9114,7 @@ var internals$jscomp$inline_1226 = {
91149114
scheduleRoot: null,
91159115
setRefreshHandler: null,
91169116
getCurrentFiber: null,
9117-
reconcilerVersion: "18.3.0-canary-493610f29-20231212"
9117+
reconcilerVersion: "18.3.0-canary-63310df2b-20231215"
91189118
};
91199119
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
91209120
var hook$jscomp$inline_1227 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9509,7 +9509,7 @@ var devToolsConfig$jscomp$inline_1075 = {
95099509
throw Error("TestRenderer does not support findFiberByHostInstance()");
95109510
},
95119511
bundleType: 0,
9512-
version: "18.3.0-canary-493610f29-20231212",
9512+
version: "18.3.0-canary-63310df2b-20231215",
95139513
rendererPackageName: "react-test-renderer"
95149514
};
95159515
var internals$jscomp$inline_1267 = {
@@ -9540,7 +9540,7 @@ var internals$jscomp$inline_1267 = {
95409540
scheduleRoot: null,
95419541
setRefreshHandler: null,
95429542
getCurrentFiber: null,
9543-
reconcilerVersion: "18.3.0-canary-493610f29-20231212"
9543+
reconcilerVersion: "18.3.0-canary-63310df2b-20231215"
95449544
};
95459545
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
95469546
var hook$jscomp$inline_1268 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (__DEV__) {
2424
) {
2525
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2626
}
27-
var ReactVersion = "18.3.0-canary-493610f29-20231212";
27+
var ReactVersion = "18.3.0-canary-63310df2b-20231215";
2828

2929
// ATTENTION
3030
// When adding new symbols to this file,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
580580
exports.useTransition = function () {
581581
return ReactCurrentDispatcher.current.useTransition();
582582
};
583-
exports.version = "18.3.0-canary-493610f29-20231212";
583+
exports.version = "18.3.0-canary-63310df2b-20231215";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ exports.useSyncExternalStore = function (
576576
exports.useTransition = function () {
577577
return ReactCurrentDispatcher.current.useTransition();
578578
};
579-
exports.version = "18.3.0-canary-493610f29-20231212";
579+
exports.version = "18.3.0-canary-63310df2b-20231215";
580580
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
581581
"function" ===
582582
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
493610f299ddf7d06e147e60dc4f2b97482982d2
1+
63310df2b243b6c3b2f01e8b121e7d115e839cfb

0 commit comments

Comments
 (0)