stripe-terminal-react-native
stripe-terminal-react-native copied to clipboard
Request: Restart the entire native SDK when Javascript app bundle is restarted (Could not execute discoverReaders because the SDK is busy with another command: discoverReaders)
Is your feature request related to a problem? Please describe.
For unrelated reasons, I have to restart the React Native app bundle programmatically if the app has been idle for too long. I implement a reader re-connect flow too whenever the app is re-booted, by discovering and connecting to a saved reader serial number.
If the javascript app bundle is restarted while running discoverReaders()
, the Cancelable
reference is lost and I can never cancel discoverReaders()
anymore. Subsequent calls to discoverReaders()
result in the error Could not execute discoverReaders because the SDK is busy with another command: discoverReaders
. Our merchants in production currently have to kill and restart the application whenever this happens.
I run into the exact same issue quite often when developing as well because of the frequent Javascript app bundle restarts (even with hot-reloading disabled). I'll have to kill the entire metro server and re-build the app to get rid of the issues and be able to discoverReaders()
again. The workaround is not too bad, just slightly annoying.
Related issues here, but none of the solutions work for me https://github.com/stripe/stripe-terminal-react-native/issues/428 https://github.com/stripe/stripe-terminal-react-native/issues/349
Describe the solution you'd like Restart the entire native SDK when Javascript app bundle is restarted
Describe alternatives you've considered
- Try to cancel discovering before the app restarts. Unfortunately the app restarts in the background and I can't be sure that the SDK has initialized by then
- Find some way to restart the entire native application instead of just doing a javascript app bundle restart. Unfortunately there's no way to do it currently because iOS doesn't expose that functionality
- Stripe SDK to expose a method to re-initialize the SDK. But this is probably going to be more clunky than simply restarting the entire SDK when the Javascript app bundle restarts.
- Stripe SDK to persist the
cancelable()
across app restarts. Probably will be clunkier than just restarting the entire SDK.
Additional context Hope I can get a response quickly because I have live merchants calling me everyday about this issue :(