Skip to content

Protect calls to native modules by default with a broad exception handler #457

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

Open
pke opened this issue Feb 10, 2022 · 0 comments
Open

Comments

@pke
Copy link

pke commented Feb 10, 2022

Introduction

There are many faulty (android) native modules out there, that often threaten the stability of the whole app just by not properly handling (runtime) exceptions.

If RN would, by default, wrap each call to native modules exported functions in an exception handler and reject a promise in case an exception happens, then the overall stability of RN apps could improve.

Details

I recently had to deal with an increasing app crash rate in the Google play console. They all happened in one native module and all of them where unchecked runtime exceptions.

I could manually handle the exceptions and create patch for the module using patch-package. And then I wondered why isn't RN pro-actively protecting its calls into 3rd party modules from the JS side using an exception handler.

try {
  callNativeModuleFunction()
} catch (RuntimeException) {
  reject(...)
}

Discussion points

  1. Speed

Maybe wrapping every call into an exception handler has speed impacts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant