From 2a45e92f33554b7f05687bb4c1a2e0406aefe079 Mon Sep 17 00:00:00 2001 From: gnoff Date: Fri, 16 Feb 2024 04:48:19 +0000 Subject: [PATCH] stash the component stack on the thrown value and reuse (#25790) ErrorBoundaries are currently not fully composable. The reason is if you decide your boundary cannot handle a particular error and rethrow it to higher boundary the React runtime does not understand that this throw is a forward and it recreates the component stack from the Boundary position. This loses fidelity and is especially bad if the boundary is limited it what it handles and high up in the component tree. This implementation uses a WeakMap to store component stacks for values that are objects. If an error is rethrown from an ErrorBoundary the stack will be pulled from the map if it exists. This doesn't work for thrown primitives but this is uncommon and stashing the stack on the primitive also wouldn't work DiffTrain build for commit https://github.com/facebook/react/commit/a9cc32511a12c261ee719e5383818182800d6af4. --- .../cjs/ReactTestRenderer-dev.js | 32 ++++-- .../cjs/ReactTestRenderer-prod.js | 98 ++++++++++--------- .../cjs/ReactTestRenderer-profiling.js | 98 ++++++++++--------- .../RKJSModules/vendor/react/cjs/React-dev.js | 2 +- .../vendor/react/cjs/React-prod.js | 2 +- .../vendor/react/cjs/React-profiling.js | 2 +- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 32 ++++-- .../implementations/ReactFabric-prod.fb.js | 50 ++++++---- .../ReactFabric-profiling.fb.js | 50 ++++++---- .../ReactNativeRenderer-dev.fb.js | 32 ++++-- .../ReactNativeRenderer-prod.fb.js | 50 ++++++---- .../ReactNativeRenderer-profiling.fb.js | 50 ++++++---- 13 files changed, 306 insertions(+), 194 deletions(-) diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js index 695fe110bc..5f0fe4d44f 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<319dc1150d695a3c1932887c45a69d77>> + * @generated SignedSource<<2bd76364e49975f7447df4d717144b25>> */ "use strict"; @@ -11931,17 +11931,37 @@ if (__DEV__) { return shouldUpdate; } + var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { // If the value is an error, call this function immediately after it is thrown // so the stack is accurate. + var stack; + + if (typeof value === "object" && value !== null) { + var capturedStack = CapturedStacks.get(value); + + if (typeof capturedStack === "string") { + stack = capturedStack; + } else { + stack = getStackByFiberInDevAndProd(source); + CapturedStacks.set(value, stack); + } + } else { + stack = getStackByFiberInDevAndProd(source); + } + return { value: value, source: source, - stack: getStackByFiberInDevAndProd(source), + stack: stack, digest: null }; } - function createCapturedValue(value, digest, stack) { + function createCapturedValueFromError(value, digest, stack) { + if (typeof stack === "string") { + CapturedStacks.set(value, stack); + } + return { value: value, source: null, @@ -14493,7 +14513,7 @@ if (__DEV__) { } error.digest = digest; - capturedValue = createCapturedValue(error, digest, stack); + capturedValue = createCapturedValueFromError(error, digest, stack); } return retrySuspenseComponentWithoutHydrating( @@ -14603,7 +14623,7 @@ if (__DEV__) { pushPrimaryTreeSuspenseHandler(workInProgress); workInProgress.flags &= ~ForceClientRender; - var _capturedValue = createCapturedValue( + var _capturedValue = createCapturedValueFromError( new Error( "There was an error while hydrating this Suspense boundary. " + "Switched to client rendering." @@ -25613,7 +25633,7 @@ if (__DEV__) { return root; } - var ReactVersion = "18.3.0-canary-2ba1b7856-20240215"; + var ReactVersion = "18.3.0-canary-a9cc32511-20240215"; // Might add PROFILE later. diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js index 2dc2b43303..5adfe182c1 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<9e3687f63a84b28f925412a2315ed394>> + * @generated SignedSource<> */ "use strict"; @@ -1351,6 +1351,18 @@ function describeFiber(fiber) { return ""; } } +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + do + (info += describeFiber(workInProgress)), + (workInProgress = workInProgress.return); + while (workInProgress); + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } +} var SuspenseException = Error( "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`" ), @@ -3557,22 +3569,23 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); } +var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { - try { - var info = "", - node = source; - do (info += describeFiber(node)), (node = node.return); - while (node); - var JSCompiler_inline_result = info; - } catch (x) { - JSCompiler_inline_result = - "\nError generating stack: " + x.message + "\n" + x.stack; - } + if ("object" === typeof value && null !== value) { + var stack = CapturedStacks.get(value); + "string" !== typeof stack && + ((stack = getStackByFiberInDevAndProd(source)), + CapturedStacks.set(value, stack)); + } else stack = getStackByFiberInDevAndProd(source); + return { value: value, source: source, stack: stack, digest: null }; +} +function createCapturedValueFromError(value, digest, stack) { + "string" === typeof stack && CapturedStacks.set(value, stack); return { value: value, - source: source, - stack: JSCompiler_inline_result, - digest: null + source: null, + stack: null != stack ? stack : null, + digest: null != digest ? digest : null }; } function logCapturedError(boundary, errorInfo) { @@ -4492,18 +4505,16 @@ function updateDehydratedSuspenseComponent( return ( pushPrimaryTreeSuspenseHandler(workInProgress), (workInProgress.flags &= -257), + (didPrimaryChildrenDefer = createCapturedValueFromError( + Error( + "There was an error while hydrating this Suspense boundary. Switched to client rendering." + ) + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: Error( - "There was an error while hydrating this Suspense boundary. Switched to client rendering." - ), - source: null, - stack: null, - digest: null - } + didPrimaryChildrenDefer ) ); if (null !== workInProgress.memoizedState) @@ -4560,17 +4571,16 @@ function updateDehydratedSuspenseComponent( "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." )), (suspenseState.digest = didPrimaryChildrenDefer), + (didPrimaryChildrenDefer = createCapturedValueFromError( + suspenseState, + didPrimaryChildrenDefer, + void 0 + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: suspenseState, - source: null, - stack: null, - digest: - null != didPrimaryChildrenDefer ? didPrimaryChildrenDefer : null - } + didPrimaryChildrenDefer ) ); didPrimaryChildrenDefer = 0 !== (renderLanes & current.childLanes); @@ -9164,19 +9174,19 @@ function wrapFiber(fiber) { fiberToWrapper.set(fiber, wrapper)); return wrapper; } -var devToolsConfig$jscomp$inline_1024 = { +var devToolsConfig$jscomp$inline_1018 = { findFiberByHostInstance: function () { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-canary-2ba1b7856-20240215", + version: "18.3.0-canary-a9cc32511-20240215", rendererPackageName: "react-test-renderer" }; -var internals$jscomp$inline_1205 = { - bundleType: devToolsConfig$jscomp$inline_1024.bundleType, - version: devToolsConfig$jscomp$inline_1024.version, - rendererPackageName: devToolsConfig$jscomp$inline_1024.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1024.rendererConfig, +var internals$jscomp$inline_1199 = { + bundleType: devToolsConfig$jscomp$inline_1018.bundleType, + version: devToolsConfig$jscomp$inline_1018.version, + rendererPackageName: devToolsConfig$jscomp$inline_1018.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1018.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9193,26 +9203,26 @@ var internals$jscomp$inline_1205 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1024.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1018.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-2ba1b7856-20240215" + reconcilerVersion: "18.3.0-canary-a9cc32511-20240215" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1206 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1200 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1206.isDisabled && - hook$jscomp$inline_1206.supportsFiber + !hook$jscomp$inline_1200.isDisabled && + hook$jscomp$inline_1200.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1206.inject( - internals$jscomp$inline_1205 + (rendererID = hook$jscomp$inline_1200.inject( + internals$jscomp$inline_1199 )), - (injectedHook = hook$jscomp$inline_1206); + (injectedHook = hook$jscomp$inline_1200); } catch (err) {} } exports._Scheduler = Scheduler; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js index bdd655f721..eff84376b7 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<501d042940fc957565aae93779730b8e>> + * @generated SignedSource<<30e0621a9f535ff1cd2b36a9447e4f81>> */ "use strict"; @@ -1371,6 +1371,18 @@ function describeFiber(fiber) { return ""; } } +function getStackByFiberInDevAndProd(workInProgress) { + try { + var info = ""; + do + (info += describeFiber(workInProgress)), + (workInProgress = workInProgress.return); + while (workInProgress); + return info; + } catch (x) { + return "\nError generating stack: " + x.message + "\n" + x.stack; + } +} var SuspenseException = Error( "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`" ), @@ -3639,22 +3651,23 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); } +var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { - try { - var info = "", - node = source; - do (info += describeFiber(node)), (node = node.return); - while (node); - var JSCompiler_inline_result = info; - } catch (x) { - JSCompiler_inline_result = - "\nError generating stack: " + x.message + "\n" + x.stack; - } + if ("object" === typeof value && null !== value) { + var stack = CapturedStacks.get(value); + "string" !== typeof stack && + ((stack = getStackByFiberInDevAndProd(source)), + CapturedStacks.set(value, stack)); + } else stack = getStackByFiberInDevAndProd(source); + return { value: value, source: source, stack: stack, digest: null }; +} +function createCapturedValueFromError(value, digest, stack) { + "string" === typeof stack && CapturedStacks.set(value, stack); return { value: value, - source: source, - stack: JSCompiler_inline_result, - digest: null + source: null, + stack: null != stack ? stack : null, + digest: null != digest ? digest : null }; } function logCapturedError(boundary, errorInfo) { @@ -4590,18 +4603,16 @@ function updateDehydratedSuspenseComponent( return ( pushPrimaryTreeSuspenseHandler(workInProgress), (workInProgress.flags &= -257), + (didPrimaryChildrenDefer = createCapturedValueFromError( + Error( + "There was an error while hydrating this Suspense boundary. Switched to client rendering." + ) + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: Error( - "There was an error while hydrating this Suspense boundary. Switched to client rendering." - ), - source: null, - stack: null, - digest: null - } + didPrimaryChildrenDefer ) ); if (null !== workInProgress.memoizedState) @@ -4658,17 +4669,16 @@ function updateDehydratedSuspenseComponent( "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." )), (suspenseState.digest = didPrimaryChildrenDefer), + (didPrimaryChildrenDefer = createCapturedValueFromError( + suspenseState, + didPrimaryChildrenDefer, + void 0 + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: suspenseState, - source: null, - stack: null, - digest: - null != didPrimaryChildrenDefer ? didPrimaryChildrenDefer : null - } + didPrimaryChildrenDefer ) ); didPrimaryChildrenDefer = 0 !== (renderLanes & current.childLanes); @@ -9592,19 +9602,19 @@ function wrapFiber(fiber) { fiberToWrapper.set(fiber, wrapper)); return wrapper; } -var devToolsConfig$jscomp$inline_1066 = { +var devToolsConfig$jscomp$inline_1060 = { findFiberByHostInstance: function () { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-canary-2ba1b7856-20240215", + version: "18.3.0-canary-a9cc32511-20240215", rendererPackageName: "react-test-renderer" }; -var internals$jscomp$inline_1246 = { - bundleType: devToolsConfig$jscomp$inline_1066.bundleType, - version: devToolsConfig$jscomp$inline_1066.version, - rendererPackageName: devToolsConfig$jscomp$inline_1066.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1066.rendererConfig, +var internals$jscomp$inline_1240 = { + bundleType: devToolsConfig$jscomp$inline_1060.bundleType, + version: devToolsConfig$jscomp$inline_1060.version, + rendererPackageName: devToolsConfig$jscomp$inline_1060.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1060.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9621,26 +9631,26 @@ var internals$jscomp$inline_1246 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1066.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1060.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-2ba1b7856-20240215" + reconcilerVersion: "18.3.0-canary-a9cc32511-20240215" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1247 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1241 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1247.isDisabled && - hook$jscomp$inline_1247.supportsFiber + !hook$jscomp$inline_1241.isDisabled && + hook$jscomp$inline_1241.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1247.inject( - internals$jscomp$inline_1246 + (rendererID = hook$jscomp$inline_1241.inject( + internals$jscomp$inline_1240 )), - (injectedHook = hook$jscomp$inline_1247); + (injectedHook = hook$jscomp$inline_1241); } catch (err) {} } exports._Scheduler = Scheduler; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js index 6ae83f6914..c5a5c228d6 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js @@ -24,7 +24,7 @@ if (__DEV__) { ) { __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); } - var ReactVersion = "18.3.0-canary-2ba1b7856-20240215"; + var ReactVersion = "18.3.0-canary-a9cc32511-20240215"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js index e29f4d24c3..a3170de4a9 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js @@ -590,4 +590,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "18.3.0-canary-2ba1b7856-20240215"; +exports.version = "18.3.0-canary-a9cc32511-20240215"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js index 70c415c17a..13833403c9 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js @@ -586,7 +586,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "18.3.0-canary-2ba1b7856-20240215"; +exports.version = "18.3.0-canary-a9cc32511-20240215"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index bc99a7e518..46448add90 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -2ba1b7856975fb350ff1cabe575e6364cc6e8465 +a9cc32511a12c261ee719e5383818182800d6af4 diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 583e3f1aa2..56a82947e7 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; @@ -14925,17 +14925,37 @@ to return true:wantsResponderID| | return shouldUpdate; } + var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { // If the value is an error, call this function immediately after it is thrown // so the stack is accurate. + var stack; + + if (typeof value === "object" && value !== null) { + var capturedStack = CapturedStacks.get(value); + + if (typeof capturedStack === "string") { + stack = capturedStack; + } else { + stack = getStackByFiberInDevAndProd(source); + CapturedStacks.set(value, stack); + } + } else { + stack = getStackByFiberInDevAndProd(source); + } + return { value: value, source: source, - stack: getStackByFiberInDevAndProd(source), + stack: stack, digest: null }; } - function createCapturedValue(value, digest, stack) { + function createCapturedValueFromError(value, digest, stack) { + if (typeof stack === "string") { + CapturedStacks.set(value, stack); + } + return { value: value, source: null, @@ -17340,7 +17360,7 @@ to return true:wantsResponderID| | } error.digest = digest; - capturedValue = createCapturedValue(error, digest, stack); + capturedValue = createCapturedValueFromError(error, digest, stack); } return retrySuspenseComponentWithoutHydrating( @@ -17450,7 +17470,7 @@ to return true:wantsResponderID| | pushPrimaryTreeSuspenseHandler(workInProgress); workInProgress.flags &= ~ForceClientRender; - var _capturedValue = createCapturedValue( + var _capturedValue = createCapturedValueFromError( new Error( "There was an error while hydrating this Suspense boundary. " + "Switched to client rendering." @@ -27652,7 +27672,7 @@ to return true:wantsResponderID| | return root; } - var ReactVersion = "18.3.0-canary-e601a9d1"; + var ReactVersion = "18.3.0-canary-f6a619c0"; function createPortal$1( children, diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 8acb6c0fe2..56c172a07c 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<1f5dcd93fe9d8ca34dd175b10f731416>> + * @generated SignedSource<> */ "use strict"; @@ -4566,12 +4566,23 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); } +var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { + if ("object" === typeof value && null !== value) { + var stack = CapturedStacks.get(value); + "string" !== typeof stack && + ((stack = getStackByFiberInDevAndProd(source)), + CapturedStacks.set(value, stack)); + } else stack = getStackByFiberInDevAndProd(source); + return { value: value, source: source, stack: stack, digest: null }; +} +function createCapturedValueFromError(value, digest, stack) { + "string" === typeof stack && CapturedStacks.set(value, stack); return { value: value, - source: source, - stack: getStackByFiberInDevAndProd(source), - digest: null + source: null, + stack: null != stack ? stack : null, + digest: null != digest ? digest : null }; } if ( @@ -5510,18 +5521,16 @@ function updateDehydratedSuspenseComponent( return ( pushPrimaryTreeSuspenseHandler(workInProgress), (workInProgress.flags &= -257), + (didPrimaryChildrenDefer = createCapturedValueFromError( + Error( + "There was an error while hydrating this Suspense boundary. Switched to client rendering." + ) + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: Error( - "There was an error while hydrating this Suspense boundary. Switched to client rendering." - ), - source: null, - stack: null, - digest: null - } + didPrimaryChildrenDefer ) ); if (null !== workInProgress.memoizedState) @@ -5578,17 +5587,16 @@ function updateDehydratedSuspenseComponent( "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." )), (suspenseState.digest = didPrimaryChildrenDefer), + (didPrimaryChildrenDefer = createCapturedValueFromError( + suspenseState, + didPrimaryChildrenDefer, + void 0 + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: suspenseState, - source: null, - stack: null, - digest: - null != didPrimaryChildrenDefer ? didPrimaryChildrenDefer : null - } + didPrimaryChildrenDefer ) ); didPrimaryChildrenDefer = 0 !== (renderLanes & current.childLanes); @@ -9529,7 +9537,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1071 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-canary-e2c52ae4", + version: "18.3.0-canary-9cc4f71b", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -9572,7 +9580,7 @@ var internals$jscomp$inline_1296 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-e2c52ae4" + reconcilerVersion: "18.3.0-canary-9cc4f71b" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1297 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 0ab5d6e230..f3ecd46314 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<7ac950cf4db25db8a235124e199f62d3>> + * @generated SignedSource<<11bbeb7ca3cf648d381cd7e5c3e700fa>> */ "use strict"; @@ -4760,12 +4760,23 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); } +var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { + if ("object" === typeof value && null !== value) { + var stack = CapturedStacks.get(value); + "string" !== typeof stack && + ((stack = getStackByFiberInDevAndProd(source)), + CapturedStacks.set(value, stack)); + } else stack = getStackByFiberInDevAndProd(source); + return { value: value, source: source, stack: stack, digest: null }; +} +function createCapturedValueFromError(value, digest, stack) { + "string" === typeof stack && CapturedStacks.set(value, stack); return { value: value, - source: source, - stack: getStackByFiberInDevAndProd(source), - digest: null + source: null, + stack: null != stack ? stack : null, + digest: null != digest ? digest : null }; } if ( @@ -5728,18 +5739,16 @@ function updateDehydratedSuspenseComponent( return ( pushPrimaryTreeSuspenseHandler(workInProgress), (workInProgress.flags &= -257), + (didPrimaryChildrenDefer = createCapturedValueFromError( + Error( + "There was an error while hydrating this Suspense boundary. Switched to client rendering." + ) + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: Error( - "There was an error while hydrating this Suspense boundary. Switched to client rendering." - ), - source: null, - stack: null, - digest: null - } + didPrimaryChildrenDefer ) ); if (null !== workInProgress.memoizedState) @@ -5796,17 +5805,16 @@ function updateDehydratedSuspenseComponent( "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." )), (suspenseState.digest = didPrimaryChildrenDefer), + (didPrimaryChildrenDefer = createCapturedValueFromError( + suspenseState, + didPrimaryChildrenDefer, + void 0 + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: suspenseState, - source: null, - stack: null, - digest: - null != didPrimaryChildrenDefer ? didPrimaryChildrenDefer : null - } + didPrimaryChildrenDefer ) ); didPrimaryChildrenDefer = 0 !== (renderLanes & current.childLanes); @@ -10228,7 +10236,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1149 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-canary-6091903d", + version: "18.3.0-canary-258577a6", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10284,7 +10292,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-6091903d" + reconcilerVersion: "18.3.0-canary-258577a6" }); exports.createPortal = function (children, containerTag) { return createPortal$1( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 782d112bd8..4178937395 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<9862dd2d5c58b910eea6bd208dabda33>> + * @generated SignedSource<<3dc9ab97890b41f48d6f4539b4ecde3d>> */ "use strict"; @@ -15197,17 +15197,37 @@ to return true:wantsResponderID| | return shouldUpdate; } + var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { // If the value is an error, call this function immediately after it is thrown // so the stack is accurate. + var stack; + + if (typeof value === "object" && value !== null) { + var capturedStack = CapturedStacks.get(value); + + if (typeof capturedStack === "string") { + stack = capturedStack; + } else { + stack = getStackByFiberInDevAndProd(source); + CapturedStacks.set(value, stack); + } + } else { + stack = getStackByFiberInDevAndProd(source); + } + return { value: value, source: source, - stack: getStackByFiberInDevAndProd(source), + stack: stack, digest: null }; } - function createCapturedValue(value, digest, stack) { + function createCapturedValueFromError(value, digest, stack) { + if (typeof stack === "string") { + CapturedStacks.set(value, stack); + } + return { value: value, source: null, @@ -17612,7 +17632,7 @@ to return true:wantsResponderID| | } error.digest = digest; - capturedValue = createCapturedValue(error, digest, stack); + capturedValue = createCapturedValueFromError(error, digest, stack); } return retrySuspenseComponentWithoutHydrating( @@ -17722,7 +17742,7 @@ to return true:wantsResponderID| | pushPrimaryTreeSuspenseHandler(workInProgress); workInProgress.flags &= ~ForceClientRender; - var _capturedValue = createCapturedValue( + var _capturedValue = createCapturedValueFromError( new Error( "There was an error while hydrating this Suspense boundary. " + "Switched to client rendering." @@ -28093,7 +28113,7 @@ to return true:wantsResponderID| | return root; } - var ReactVersion = "18.3.0-canary-98bf82e6"; + var ReactVersion = "18.3.0-canary-b3071bed"; function createPortal$1( children, diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 1e057c64a3..5a35ec8bbd 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<3211cd1fbaae6ce4edc1706d0eabd286>> + * @generated SignedSource<<4ab98123eefb86214c2e00d10a6369be>> */ "use strict"; @@ -4631,12 +4631,23 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); } +var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { + if ("object" === typeof value && null !== value) { + var stack = CapturedStacks.get(value); + "string" !== typeof stack && + ((stack = getStackByFiberInDevAndProd(source)), + CapturedStacks.set(value, stack)); + } else stack = getStackByFiberInDevAndProd(source); + return { value: value, source: source, stack: stack, digest: null }; +} +function createCapturedValueFromError(value, digest, stack) { + "string" === typeof stack && CapturedStacks.set(value, stack); return { value: value, - source: source, - stack: getStackByFiberInDevAndProd(source), - digest: null + source: null, + stack: null != stack ? stack : null, + digest: null != digest ? digest : null }; } if ( @@ -5575,18 +5586,16 @@ function updateDehydratedSuspenseComponent( return ( pushPrimaryTreeSuspenseHandler(workInProgress), (workInProgress.flags &= -257), + (didPrimaryChildrenDefer = createCapturedValueFromError( + Error( + "There was an error while hydrating this Suspense boundary. Switched to client rendering." + ) + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: Error( - "There was an error while hydrating this Suspense boundary. Switched to client rendering." - ), - source: null, - stack: null, - digest: null - } + didPrimaryChildrenDefer ) ); if (null !== workInProgress.memoizedState) @@ -5643,17 +5652,16 @@ function updateDehydratedSuspenseComponent( "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." )), (suspenseState.digest = didPrimaryChildrenDefer), + (didPrimaryChildrenDefer = createCapturedValueFromError( + suspenseState, + didPrimaryChildrenDefer, + void 0 + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: suspenseState, - source: null, - stack: null, - digest: - null != didPrimaryChildrenDefer ? didPrimaryChildrenDefer : null - } + didPrimaryChildrenDefer ) ); didPrimaryChildrenDefer = 0 !== (renderLanes & current.childLanes); @@ -9750,7 +9758,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1140 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-canary-8adfe207", + version: "18.3.0-canary-eb3a3b11", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -9793,7 +9801,7 @@ var internals$jscomp$inline_1379 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-8adfe207" + reconcilerVersion: "18.3.0-canary-eb3a3b11" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1380 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index cd40ccba97..799f3ac8c4 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; @@ -4824,12 +4824,23 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4194308); } +var CapturedStacks = new WeakMap(); function createCapturedValueAtFiber(value, source) { + if ("object" === typeof value && null !== value) { + var stack = CapturedStacks.get(value); + "string" !== typeof stack && + ((stack = getStackByFiberInDevAndProd(source)), + CapturedStacks.set(value, stack)); + } else stack = getStackByFiberInDevAndProd(source); + return { value: value, source: source, stack: stack, digest: null }; +} +function createCapturedValueFromError(value, digest, stack) { + "string" === typeof stack && CapturedStacks.set(value, stack); return { value: value, - source: source, - stack: getStackByFiberInDevAndProd(source), - digest: null + source: null, + stack: null != stack ? stack : null, + digest: null != digest ? digest : null }; } if ( @@ -5792,18 +5803,16 @@ function updateDehydratedSuspenseComponent( return ( pushPrimaryTreeSuspenseHandler(workInProgress), (workInProgress.flags &= -257), + (didPrimaryChildrenDefer = createCapturedValueFromError( + Error( + "There was an error while hydrating this Suspense boundary. Switched to client rendering." + ) + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: Error( - "There was an error while hydrating this Suspense boundary. Switched to client rendering." - ), - source: null, - stack: null, - digest: null - } + didPrimaryChildrenDefer ) ); if (null !== workInProgress.memoizedState) @@ -5860,17 +5869,16 @@ function updateDehydratedSuspenseComponent( "The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering." )), (suspenseState.digest = didPrimaryChildrenDefer), + (didPrimaryChildrenDefer = createCapturedValueFromError( + suspenseState, + didPrimaryChildrenDefer, + void 0 + )), retrySuspenseComponentWithoutHydrating( current, workInProgress, renderLanes, - { - value: suspenseState, - source: null, - stack: null, - digest: - null != didPrimaryChildrenDefer ? didPrimaryChildrenDefer : null - } + didPrimaryChildrenDefer ) ); didPrimaryChildrenDefer = 0 !== (renderLanes & current.childLanes); @@ -10448,7 +10456,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1218 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-canary-14b7ed0a", + version: "18.3.0-canary-dcf1c7af", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10504,7 +10512,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-canary-14b7ed0a" + reconcilerVersion: "18.3.0-canary-dcf1c7af" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function (reactTag) {