Skip to content

refactor: merge std::runtime_error catch blocks in host functions - #1109

Merged
msluszniak merged 1 commit into
mainfrom
@ms/merge-host-function-catch-blocks
Apr 29, 2026
Merged

refactor: merge std::runtime_error catch blocks in host functions#1109
msluszniak merged 1 commit into
mainfrom
@ms/merge-host-function-catch-blocks

Conversation

@msluszniak

Copy link
Copy Markdown
Member

Summary

  • Removes the redundant std::runtime_error (and jsi::JSError) catch blocks across ModelHostObject.h and RnExecutorchInstaller.h. They were workarounds for broken RTTI in older RN versions; the fix from react/react-native@3132cc8 is present in RN 0.81+, which is the project's minimum supported version.
  • All five sites now catch std::exception polymorphically: synchronousHostFunction, visionHostFunction, promiseHostFunction, unload, and the model loader in RnExecutorchInstaller.

Closes #964

Test plan

  • C++ unit/integration tests in common/rnexecutorch/tests pass on Android (run_tests.sh)
  • Smoke-test an example app: trigger a model load failure and a forward-pass failure, confirm error message + code propagate to JS unchanged

The separate std::runtime_error catches were a workaround for broken
RTTI in older React Native versions. The fix from
react/react-native@3132cc8 is present in RN 0.81+, which is the
project's minimum supported version, so std::runtime_error can now
be caught polymorphically via std::exception.

Closes #964
@msluszniak msluszniak self-assigned this Apr 29, 2026
@msluszniak
msluszniak requested a review from mkopcins April 29, 2026 08:27

@chmjkb chmjkb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@msluszniak
msluszniak merged commit 6667f3c into main Apr 29, 2026
4 checks passed
@msluszniak
msluszniak deleted the @ms/merge-host-function-catch-blocks branch April 29, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merge catch blocks in the host function definitions

2 participants