Skip to content

iOS crash -[SentryLog count]: unrecognized selector when beforeSendLog is set and the native SDK emits a log #6842

Closed

Description

@Oupsla

Environment

  • @sentry/react-native 8.29.0 (sentry-cocoa 9.30.0, prebuilt xcframework)
  • React Native 0.86.3, New Architecture / bridgeless, Hermes, Expo SDK 57
  • iOS 18.7 (iPhone XR), Release build
  • Worked on 7.11.0 with the same configuration

Steps to reproduce

  1. Sentry.init({ dsn, enableLogs: true, beforeSendLog: (log) => log })
  2. Emit a log from the native side, e.g. from a native module in Swift: SentrySDK.logger.info("hello")
  3. The app crashes as soon as the native logger processes the log.

Actual result

*** Terminating app due to uncaught exception 'RCTFatalException: NSException:
-[Sentry.SentryLog count]: unrecognized selector sent to instance 0x126189400
  ...
  React  facebook::react::TurboModuleConvertUtils::convertJSIFunctionToCallback(...)
  React  facebook::react::AsyncCallback<>::callWithFunction(...)

Expected result

No crash. The native log is sent, or at least ignored by the JS beforeSendLog.

Cause

NATIVE.initNativeSdk in packages/core/src/js/wrapper.ts strips the callbacks that native cannot run: beforeSend, beforeBreadcrumb, beforeSendTransaction and beforeSendMetric. It doesn't strip beforeSendLog (nor beforeSendSpan). So the JS function crosses the bridge as an RCTResponseSenderBlock, which takes an NSArray *. sentry-cocoa 9 reads beforeSendLog from the options dictionary and calls the block with a SentryLog, and the block calls -count on it.

Suggested fix

Add beforeSendLog and beforeSendSpan to the destructured and stripped keys in initNativeSdk. We applied that with patch-package, and the crash is gone:

-const { beforeSend, beforeBreadcrumb, beforeSendTransaction, beforeSendMetric, integrations, ...
+const { beforeSend, beforeBreadcrumb, beforeSendTransaction, beforeSendMetric, beforeSendLog, beforeSendSpan, integrations, ...

Related: #5158 (running beforeSendLog on native logs).

Activity

  1. linear-code commented on Oct 5, 2026

    @linear-code
  2. self-assigned this
    on Oct 6, 2026
  3. alwx commented on Oct 6, 2026

    @alwx
    Contributor

    Thanks for reporting. We've seen your request and added it to our triage queue.

    We'll review it shortly and follow up if we need more information or once next steps are clearer.

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 6, 2026
  5. added 2 commits that reference this issue on Oct 6, 2026
    c5500c0
    1236b6e
  6. github-actions commented on Oct 8, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #6847, which was included in the 8.30.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions