Skip to content

Add @try/@catch exception guards to iOS TurboModule bridge#422

Merged
NickSxti merged 1 commit intodevelopfrom
fix/dev-637-add-try-catch-exception-guards
Mar 10, 2026
Merged

Add @try/@catch exception guards to iOS TurboModule bridge#422
NickSxti merged 1 commit intodevelopfrom
fix/dev-637-add-try-catch-exception-guards

Conversation

@NickSxti
Copy link
Contributor

@NickSxti NickSxti commented Mar 6, 2026

Summary

  • Add @try/@catch exception guards to all TurboModule bridge methods in RNQonversion.mm and RNNoCodes.mm
  • Prevents NSExceptions from reaching RCTTurboModule.mm's performVoidMethodInvocation, which rethrows them as C++ exceptions causing std::terminate → SIGABRT on React Native New Architecture
  • Promise methods: caught exceptions are surfaced via reject("QONBridgeException", ...)
  • Void methods & delegate callbacks: caught exceptions are logged via NSLog
  • dispatch_async blocks (NoCodes showScreen/close): guards placed inside the block to catch exceptions on the main queue

Fixes #421
Upstream RN bug: facebook/react-native#54859
Linear: DEV-637

Test plan

  • iOS build succeeds locally (example app, Debug, iphonesimulator)
  • Manual test: inject @throw in an impl method → verify crash is caught and logged, not fatal
  • Verify on New Architecture (newArchEnabled: true)
  • Verify on Old Architecture (newArchEnabled: false) — no regressions

🤖 Generated with Claude Code

@NickSxti NickSxti requested a review from SpertsyanKM March 6, 2026 13:44
Prevent NSExceptions from propagating to RCTTurboModule's
performVoidMethodInvocation, which rethrows them as C++ exceptions
causing std::terminate → SIGABRT on React Native New Architecture.

- Void methods: catch and log via NSLog
- Promise methods: catch and reject with QONBridgeException error code
- Delegate callbacks: catch and log
- dispatch_async blocks (NoCodes): guards placed inside the block

Fixes: #421
Upstream RN bug: facebook/react-native#54859

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@NickSxti NickSxti force-pushed the fix/dev-637-add-try-catch-exception-guards branch from 6a1b502 to 1729b2b Compare March 6, 2026 14:01
@NickSxti
Copy link
Contributor Author

NickSxti commented Mar 6, 2026

Local verification

Build: BUILD SUCCEEDED — iPhone 16 Pro simulator, iOS 18.3.1
Runtime: App launched and ran without crashes (confirmed process alive via launchctl + ps)
Logs: No NSException, SIGABRT, or QONBridgeException in simulator logs — normal operation path unaffected

Code review notes

  • Only 2 files changed: RNQonversion.mm and RNNoCodes.mm
  • Pattern is consistent:
    • Promise methods@try/@catch with reject("QONBridgeException", ...)
    • Void methods@try/@catch with NSLog
    • Delegate callbacks@try/@catch with NSLog
    • dispatch_async blocks → guard placed inside the block
  • Normal SandwichErrorreject() flow is not affected@catch only catches NSException

Screenshot:
qonversion_screenshot

@NickSxti NickSxti merged commit 334c41d into develop Mar 10, 2026
1 check passed
@NickSxti NickSxti deleted the fix/dev-637-add-try-catch-exception-guards branch March 10, 2026 14:29
@NickSxti NickSxti mentioned this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Screen with Qonversion imported crashes

2 participants