react / react/react-native

Runtime Exceptions in TurboModule Void Methods Crash the App

Offen
#53,960 8 Kommentare 8 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Issue: Author Provided Repro Needs: React Native Team Attention Type: New Architecture
Vorherrschende Sprache
C++
Sterne
127k
Forks
25.3k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
4

Beschreibung

Description

When raising a runtime exception (RuntimeException on Android, NSException on iOS) in a TurboModule the behavior is different based on whether the method in the TurboModule has a return type or is declared as void.

If the method that raises the exception has a return type, the exception is visible in the Javascript code that called the method. The error can be handled in a catch statement and if it's not then the standard error screen is shown in development.

If the method that raises the exception is declared as void, the behavior is slightly different between iOS and Android. On iOS, the app immediately crashes (if a debugger is attached, the cause is often EXC_BAD_ACCESS). On Android, the standard error screen is shown but then the app stops responding (the UI goes white and the app is frozen).

This reproducer project has a TurboModule with two methods: nonVoidFunction and voidFunction. Each is implemented to raise a runtime exception. There are two buttons on the main screen, one to call each function. Tapping the "Non Void Function" button calls the corresponding function and the standard error screen is displayed. After dismissing or minimizing the error, the app continues to function. Tapping the "Void Function" button exhibits the behavior described above (white screen on Android, crash on iOS).

Reproducer Project

Steps to reproduce
  1. Clone the reproducer project
  2. Run the application and tap the "Void Function" button
React Native Version

0.81.4

Affected Platforms

Runtime - Android, Runtime - iOS

Areas

TurboModule - The New Native Module System

Output of npx @react-native-community/cli info
System:
  OS: macOS 15.7
  CPU: (12) arm64 Apple M4 Pro
  Memory: 125.47 MB / 24.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.14.0
    path: ~/.nvm/versions/node/v22.14.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v22.14.0/bin/yarn
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v22.14.0/bin/npm
  Watchman:
    version: 2024.12.02.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.25410.109.2511.13752376
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.14
    path: /usr/bin/javac
  Ruby:
    version: 2.7.2
    path: /Users/sean/.asdf/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.4
    wanted: 0.81.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Stacktrace or Logs
Not available. See description and reproduction steps above.
MANDATORY Reproducer

https://github.com/picassomd/turbo-modules-exceptions

Screenshots and Videos

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem obligatorischen Reproduktionsprojekt und vergleiche die auf Android und iOS benannten TurboModule-Methoden nonVoidFunction und voidFunction. Verfolge, wie Laufzeitausnahmen aus void-Methoden im Vergleich zu Methoden mit Rückgabetypen behandelt werden. Als erledigt gilt die Aufgabe, wenn Ausnahmen aus void-Methoden JavaScript konsistent erreichen, ohne das Einfrieren unter Android oder den Absturz unter iOS.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, ios, react-native
Bereich
mobile-dev
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.