Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide default implementation for ReactHostDelegate.handleInstanceException() #45521

Closed
wants to merge 1 commit into from

Conversation

alanleedev
Copy link
Contributor

Summary:
ReactHostDelegate.handleInstanceException() is a no-op so providing a default implementation for this.
As a simplified solution, just throw a RuntimeException (on non-debug bulid) in this case. Below is the justification.

  1. We may want to consider using ExceptionsManagerModule TurboModule in OSS to report the exception but current implementation just throws JavaScriptException when it is fatal

  2. If the exception happens during ReactInstance initialization then we may not have Turbo Module initialized and may not be able to access it. While we might want to fix how this works in longer term but for now just throw an Exception and let the app handle it.

  3. In debug build, DevSupportManager is called before handleInstanceException() which would display a RedBox so don't throw when it is a debug build.

So it seems to best for now to just throw an exception so it can be handled by the app than silently ignoring it.

Changelog:
[General][Android] - provide default implementation for ReactHostDelegate.handleInstanceException()

Differential Revision: D59847543

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Jul 18, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D59847543

…ception() (facebook#45521)

Summary:
Pull Request resolved: facebook#45521

[ReactHostDelegate.handleInstanceException()](https://github.com/facebook/react-native/blob/a6f5e5adebed3d9da411f99548e2d8ce96636e16/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHostDelegate.kt#L48) is a no-op so providing a default implementation for this.
As a simplified solution, just throw a `RuntimeException` (on non-debug bulid) in this case. Below is the justification.

1) We may want to consider using `ExceptionsManagerModule` TurboModule in OSS to report the exception but current implementation  just [throws JavaScriptException](https://github.com/facebook/react-native/blob/a6f5e5adebed3d9da411f99548e2d8ce96636e16/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java#L67) when it is fatal

2) If the exception happens during ReactInstance initialization then we may not have Turbo Module initialized and may not be able to access it. While we might want to fix how this works in longer term but for now just throw an Exception and let the app handle it.

3) In debug build, `DevSupportManager` is called before `handleInstanceException()` which would display a RedBox so don't throw when it is a debug build.

So it seems to best for now to just throw an exception so it can be handled by the app than silently ignoring it.

Changelog:
[Android][Added] - provide default implementation for ReactHostDelegate.handleInstanceException()

Reviewed By: javache

Differential Revision: D59847543
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D59847543

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 34e3a6c.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @alanleedev in 34e3a6c

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants