Please sign in to comment.
Move React error message formatting into ExceptionsManager
Summary: # Context In facebook/react#16141 we imported `ReactFiberErrorDialog` unchanged from React. That implementation was not idempotent: if passed the same error instance multiple times, it would amend its `message` property every time, eventually leading to bloat and low-signal logs. The message bloat problem is most evident when rendering multiple `lazy()` components that expose the same Error reference to React (e.g. due to some cache that vends the same rejected Promise multiple times). More broadly, there's a need for structured, machine-readable logging to replace stringly-typed interfaces in both the production and development use cases. # This diff * We leave the user-supplied `message` field intact and instead do all the formatting inside `ExceptionsManager`. To avoid needless complexity, this **doesn't** always have the exact same output as the old code (but it does come close). See tests for the specifics. * The only mutation we do on React-captured error instances is setting the `componentStack` expando property. This replaces any previously-captured component stack rather than adding to it, and so doesn't create bloat. * We also report the exception fields `componentStack`, unformatted `message` (as `originalMessage`) and `name` directly to `NativeExceptionsManager` for future use. Reviewed By: cpojer Differential Revision: D16331228 fbshipit-source-id: 7b0539c2c83c7dd4e56db8508afcf367931ac71d
- Loading branch information...
Showing with 171 additions and 42 deletions.
- +1 −0 Libraries/Core/Devtools/parseErrorStack.js
- +38 −11 Libraries/Core/ExceptionsManager.js
- +3 −0 Libraries/Core/NativeExceptionsManager.js
- +14 −18 Libraries/Core/ReactFiberErrorDialog.js
- +95 −11 Libraries/Core/__tests__/ExceptionsManager-test.js
- +18 −0 Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h
- +2 −2 RNTester/RNTesterIntegrationTests/RCTLoggingTests.m
Oops, something went wrong.