Skip to content

2.1.1 throws unhandled exception - Crash  #237

@Qwin

Description

@Qwin

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

  1. Add react-native-share 7.1.x or 7.2.0 to the project
  2. open new share tab in android click on gmail
  3. in gmail exit out and go back to the app
  4. 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.

image

SyncWebAuthClient
image

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"

Metadata

Metadata

Labels

androidAndroid related

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions