GoogleCloudPlatform / recaptcha-enterprise-mobile-sdk

Apache License 2.0
29 stars 5 forks source link

[Bug]: Many errors to initilize client, get token and internal errors #85

Closed noa-raz closed 6 months ago

noa-raz commented 8 months ago

Are you seeing the problem on Android or iOS?

Android

Contact Details

noa.raz@plus500.com

Describe the bug

Many errors to initilize client, get token and internal errors

Site Key

Will be provided if requested

Select the method used to integrate with reCAPTCHA Mobile.

GMaven (Android)

SDK Version

18.4.0

To Reproduce

we couldn't reproduce it in our dev environment or tests. We se in out production environment many users cant get token, and through crashlytics there are about 2.7k of exceptions in the last 7 days.

Expected behavior

No response

Development IDE

Android Studio Hedgehog | 2023.1.1 Patch 2

To Reproduce

image

there are the metrics from chrashlytics

Relevant log output

at com.google.android.recaptcha.internal.zzav.invokeSuspend(com.google.android.recaptcha:recaptcha@@18.4.0:279)     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:12)   at kotlinx.coroutines.a1.run(DispatchedTask.kt:124)     at kotlinx.coroutines.internal.q$a.run(LimitedDispatcher.kt:4)  at kotlinx.coroutines.scheduling.m.run(Tasks.kt:3)  at kotlinx.coroutines.scheduling.CoroutineScheduler.u0(CoroutineScheduler.kt:1)     at kotlinx.coroutines.scheduling.CoroutineScheduler$c.d(CoroutineScheduler.kt:15)   at kotlinx.coroutines.scheduling.CoroutineScheduler$c.u(CoroutineScheduler.kt:29)   at kotlinx.coroutines.scheduling.CoroutineScheduler$c.run(CoroutineScheduler.kt:1)

com.google.android.recaptcha.RecaptchaException: Internal Error
    at com.google.android.recaptcha.internal.zzam.zza(com.google.android.recaptcha:recaptcha@@18.4.0:430)
    at com.google.android.recaptcha.internal.zzai.invokeSuspend(com.google.android.recaptcha:recaptcha@@18.4.0:21)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:12)
    at kotlinx.coroutines.internal.k0.p1(Scopes.kt:7)
    at kotlinx.coroutines.a.resumeWith(AbstractCoroutine.kt:16)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:50)
    at kotlinx.coroutines.internal.k0.p1(Scopes.kt:7)
    at kotlinx.coroutines.a.resumeWith(AbstractCoroutine.kt:16)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:50)
    at kotlinx.coroutines.a1.run(DispatchedTask.kt:110)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7986)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:553)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

com.google.android.recaptcha.RecaptchaException: Internal Error
    at com.google.android.recaptcha.internal.zzam.zza(com.google.android.recaptcha:recaptcha@@18.4.0:430)
    at com.google.android.recaptcha.internal.zzai.invokeSuspend(com.google.android.recaptcha:recaptcha@@18.4.0:21)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:12)
    at kotlinx.coroutines.internal.k0.p1(Scopes.kt:7)
    at kotlinx.coroutines.a.resumeWith(AbstractCoroutine.kt:16)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:50)
    at kotlinx.coroutines.internal.k0.p1(Scopes.kt:7)
    at kotlinx.coroutines.a.resumeWith(AbstractCoroutine.kt:16)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:50)
    at kotlinx.coroutines.a1.run(DispatchedTask.kt:110)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7986)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:553)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Relevant log output

image

walterjgsp commented 8 months ago

Thanks for the detailed report @noa-raz. We will do our best effort to investigate this! This also seems related to SDK version 18.3.0. Can you please quantify the frequency of the error (e.g., what percentage of requests are affected)?

Just to confirm but in your report I imagine that we have two stack traces instead of 3, correct?

noa-raz commented 8 months ago

Hey @walterjgsp thanks for the quick reply. We updated our latest app version with sdk version 18.4.0, most of our exceptions are with this version. Regarding the stack traces, I chose randomly a few, I can add more if needed.

is there anything we can add in our code to reduce the amount currently? will retry mechanism could help?

walterjgsp commented 7 months ago

Is there anything we can add in our code to reduce the amount currently? will retry mechanism could help?

@noa-raz, our experience shows that adding retry mechanisms to getClient and execute can reduce exceptions, that was going to be my next suggestion.

If in need of inspiration we do have a sample code implementing retry in the example folder.

Regarding the stack traces, I chose randomly a few, I can add more if needed.

For the stack trace, can you please share the one that you're seeing most frequently?

noa-raz commented 7 months ago

Thanks @walterjgsp , I'll add retry. looks like most frequent exception is for getClient.

at com.google.android.recaptcha.internal.zzbq.zza(com.google.android.recaptcha:recaptcha@@18.4.0:144)   
at com.google.android.recaptcha.internal.zzal.invokeSuspend(com.google.android.recaptcha:recaptcha@@18.4.0:151) 
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:12)   
at kotlinx.coroutines.a1.run(DispatchedTask.kt:124)     
at kotlinx.coroutines.internal.q$a.run(LimitedDispatcher.kt:4)  
at kotlinx.coroutines.scheduling.m.run(Tasks.kt:3)  
at kotlinx.coroutines.scheduling.CoroutineScheduler.u0(CoroutineScheduler.kt:1)     
at kotlinx.coroutines.scheduling.CoroutineScheduler$c.d(CoroutineScheduler.kt:15)   
at kotlinx.coroutines.scheduling.CoroutineScheduler$c.u(CoroutineScheduler.kt:29)   
at kotlinx.coroutines.scheduling.CoroutineScheduler$c.run(CoroutineScheduler.kt:1)

and this one is the most frequent for execute

com.google.android.recaptcha.RecaptchaException: Network Error
    at com.google.android.recaptcha.internal.zzav.invokeSuspend(com.google.android.recaptcha:recaptcha@@18.4.0:279)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:12)
    at kotlinx.coroutines.a1.run(DispatchedTask.kt:124)
    at kotlinx.coroutines.internal.q$a.run(LimitedDispatcher.kt:4)
    at kotlinx.coroutines.scheduling.m.run(Tasks.kt:3)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.u0(CoroutineScheduler.kt:1)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$c.d(CoroutineScheduler.kt:15)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$c.u(CoroutineScheduler.kt:29)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$c.run(CoroutineScheduler.kt:1)
walterjgsp commented 7 months ago

Thanks for the stack traces @noa-raz! This will help us a lot in the investigation. We do have planned a new beta release that should improve the Network Errors that you're probably seeing. I will update you when we release it.

For the first one what's the exception that you're receiving? Also a Network Error?

mcorner commented 6 months ago

The original issue contained two parts: network errors and internal errors. We believe we have addressed the internal errors in 18.5.0-beta02. Please give that a try.

Networking errors have been traced to calling the API when there is no network (and confirmed by Android apis). The sdk must have networking while initializing and the only mitigation at the moment is to retry when it does. We are working on a new API to internalize these retries (likely in 18.6).

So there isn't a "bug" but we recognize it could be easier to use and we are working hard.on that (next few months).