Skip to content

fix: parseErrorStack export in reactotron-react-native#1588

Merged
joshuayoes merged 1 commit into
masterfrom
fix/track-global-error-stackframe
Oct 13, 2025
Merged

fix: parseErrorStack export in reactotron-react-native#1588
joshuayoes merged 1 commit into
masterfrom
fix/track-global-error-stackframe

Conversation

@joshuayoes
Copy link
Copy Markdown
Contributor

@joshuayoes joshuayoes commented Oct 10, 2025

Please verify the following:

  • yarn build-and-test:local passes
  • I have added tests for any new features, if relevant
  • README.md (or relevant documentation) has been updated with your changes

Describe your PR

This PR fixes module loading issues in the trackGlobalErrors plugin where React Native's internal error stack parsing utilities could fail to load properly.

Resolves #1573

Changes

  • Added support for both CommonJS (module.exports) and ESM (export default) module formats when requiring parseErrorStack and symbolicateStackTrace from React Native
  • Added runtime validation to ensure loaded utilities are functions before use
  • Enhanced error reporting with detailed debug logging including:
    • Availability checks for each utility
    • Type information when validation fails
    • Module structure details for debugging

Problem

The previous implementation assumed a specific module export format from React Native's internal modules (react-native/Libraries/Core/Devtools/parseErrorStack and symbolicateStackTrace), which could fail in certain React Native versions or build configurations, causing error tracking to silently fail.

Solution

  • Lazy-load modules inside reportError only when needed
  • Check if the required module is a direct function export or has a default property
  • Validate that loaded utilities are actually functions before attempting to use them
  • Provide actionable error messages and debug information when something goes wrong

Testing / Reproduction Steps

  1. Checkout this PR
  2. Run yarn build in the reactotron repository
  3. Create a new Ignite app: npx ignite-cli@latest new PizzaApp
  4. Apply the following diff to add a test error button in PizzaApp:
diff --git a/app/screens/DemoDebugScreen.tsx b/app/screens/DemoDebugScreen.tsx
index bf569ec..898ad2e 100644
--- a/app/screens/DemoDebugScreen.tsx
+++ b/app/screens/DemoDebugScreen.tsx
@@ -59,6 +59,15 @@ export const DemoDebugScreen: FC<DemoTabScreenProps<"DemoDebug">> = function Dem
     [],
   )
 
+  const demoReactotronError = useMemo(
+    () => async () => {
+      if (__DEV__) {
+        console.error(new Error("This is a test error from DemoDebugScreen"))
+      }
+    },
+    [],
+  )
+
   const toggleTheme = useCallback(() => {
     LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) // Animate the transition
     setThemeContextOverride(themeContext === "dark" ? "light" : "dark")
@@ -145,6 +154,13 @@ export const DemoDebugScreen: FC<DemoTabScreenProps<"DemoDebug">> = function Dem
         <Button style={themed($button)} tx="demoDebugScreen:reactotron" onPress={demoReactotron} />
         <Text style={themed($hint)} tx={`demoDebugScreen:${Platform.OS}ReactotronHint` as const} />
       </View>
+      <View style={themed($buttonContainer)}>
+        <Button
+          style={themed($button)}
+          text="Send Error to Reactotron"
+          onPress={demoReactotronError}
+        />
+      </View>
       <View style={themed($buttonContainer)}>
         <Button style={themed($button)} tx="common:logOut" onPress={logout} />
       </View>
  1. Install the updated Reactotron packages in the Ignite app: npx zx scripts/install-workspace-packages-in-target.mjs ~/Code/PizzaApp
  2. Start the app in the Ignite app
  3. Navigate to the Debug screen
  4. Click on the "Send Error to Reactotron" button
  5. See the error log appear in the Reactotron timeline
  6. Expand the timeline log to see the stack frame with proper symbolication
Screenshot 2025-10-10 at 9 31 52 AM

… availability and function types. Added detailed logging for missing or invalid modules.
@joshuayoes joshuayoes self-assigned this Oct 10, 2025
@joshuayoes joshuayoes added the bug 🪲 Nope, this is wrong. label Oct 10, 2025
@joshuayoes joshuayoes merged commit 65dd6b7 into master Oct 13, 2025
7 checks passed
@joshuayoes joshuayoes deleted the fix/track-global-error-stackframe branch October 13, 2025 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🪲 Nope, this is wrong.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parseErrorStack in reactotron-react-native not working

2 participants