-
Couldn't load subscription status.
- Fork 45
Description
I'm submitting a:
- Bug report
- Feature request
- Other (Describe below)
Current behavior
When using react-native-share library (7.2.0) and opening a share tab and then tapping on any of the services (gmail) and then going back to the app, Okta throws the following exception causing the app to crash, I debugged the code and it seems like onCancel is being invoked and queuedPromise is null.
java.lang.NullPointerException: Attempt to invoke interface method 'void com.facebook.react.bridge.Promise.reject(java.lang.String, java.lang.String)' on a null object reference
at com.oktareactnative.OktaSdkBridgeModule$4.onCancel(OktaSdkBridgeModule.java:527)
at com.okta.oidc.clients.web.WebAuthClientImpl.lambda$processSignInResult$5$WebAuthClientImpl(WebAuthClientImpl.java:174)
at com.okta.oidc.clients.web.-$$Lambda$WebAuthClientImpl$0_cBT7GLb2JTAuHwaE7paM-RoKQ.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Expected behavior
Does not fire SignIn event on threadpool abrupt kill of task, does not crash on queuedPromise.
Minimal reproduction of the problem with instructions
- Add react-native-share 7.1.x or 7.2.0 to the project
- open new share tab in android click on gmail
- in gmail exit out and go back to the app
- Above crash happens
Extra information about the use case/user story you are trying to implement
After looking further I see that the ThreadExecutor somehow cancels the futureTask (somehow in conflict with the pools with the share library maybe) in webAuthClient. Causing the registerCallback in WebAuthClientImpl to be invoked with type SIGN_IN and result CANCELLED. Again nobody invoked SignIn so the queuedPromise is null thus a crash happens.
I added a simple if statement for queuedPromise as a test on the canceled method, which solved the crashing of course, and the app functions normally and the token is still valid as well. But I am puzzled as to what is happening here. Of course it would be great if you guys added a null check just for safety but honestly it should never fire.... its just a workaround afterall.
This does not happen in version 1.12.1 of okta-react-native.
Environment
- Package Version: 2.1.1
- React Native Version: 0.64.2
- OS: Mac OS / Android 11
- Node version (
node -v): v14.18.0 - Other: "react-native-share": "^7.2.0"

