Skip to content

Native crash autocapture double-reports fatal React Native JS errors (JavascriptException) #567

Closed

Description

@ioannisj

Problem

When the React Native SDK enables native crash autocapture (@posthog/react-native-plugin, errorTracking.autocapture.nativeCrashes, see PostHog/posthog-js#3677), a fatal JS error can be captured twice:

  1. The JS layer captures it via uncaughtExceptions autocapture (with the JS stack trace), and
  2. React Native rethrows fatal JS errors on the native side as a com.facebook.react.common.JavascriptException on the main thread. posthog-android's uncaught-exception handler then captures it as a separate native crash (with a native stack trace).

The result is two $exception events for one logical error.

Suggested fix

posthog-android should expose a way to ignore exceptions that originate from React Native's fatal-JS path, and/or skip reporting throwables of type com.facebook.react.common.JavascriptException, so the JS-captured event is the single source of truth.

For reference, sentry-react-native does exactly this on the native side:

// React native internally throws a JavascriptException.
// we want to ignore it on the native side to avoid sending it twice.
options.addIgnoredExceptionForType(JavascriptException.class);

(https://github.com/getsentry/sentry-react-native/blob/f170ec355cd622d3e935478a23660ad4cb97e896/packages/core/android/src/main/java/io/sentry/react/RNSentryStart.java#L355)

Notes

Activity

  1. marandaneto commented on Jun 11, 2026

    @marandaneto
    Member

    you can use the beforeSend callback and match the com.facebook.react.common.JavascriptException with the $ elements that expose the class name and package and drop it for now

  2. added a commit that references this issue on Jul 20, 2026
    ef8f1d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions