-
-
Notifications
You must be signed in to change notification settings - Fork 624
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
"Unable to auto-initialize connection" message on Android (and some suggestions) #2265
Comments
It makes sense to have the option to catch the error or ignore it. This is a bug |
Thanks for the reply! I'm most curious why it's happening in the first place, given that I seem to be following all of the guidelines around connection status, but having the option to silently ignore it would be nice. |
How about something like
In that way, it has a default value so it's not a breaking change |
Sure, that works. Though I think that re-throwing the error from inside the Promise technically retains the previous behavior, which is that the error will go uncaught rather than swallowed. |
Upon further research, I went with: #2268. |
Released as |
Same for us. We also experience this issue again with version 12.13.1. |
Description
First, thank you all of the work you do on this module! It's immensely helpful! Unfortunately, I am seeing thousands of promise rejections from Android devices with the message
Unable to auto-initialize connection
. I noticed that others have reported this (#2183, #1958), but there's not enough information in there to help me figure out what's going on. For what it's worth, I believe this is mostly just a warning message. I haven't seen this interfering with purchasing rates on Android.For context, I am using the
withIAPContext
HOC at the top level of my app, and then a hook that attaches anonPurchaseUpdated
listener in order to act on changes to the latest purchase.Simplified, that hook looks like this:
And here's the stacktrace I see in Bugsnag:
So I looked into it a bit, and
purchaseUpdatedListener
comes fromeventEmitter.ts
. The relevant lines are:…which then calls
startListening
fromRNIapModule.kt
. That callssendUnconsumedPurchases
, which callsensureConnection
, which is where thisUnable to auto-initialize connection
message originates. Ultimately, I don't understand how all of the native code works well enough to make a diagnosis to the root cause, but one thing that I find somewhat strange is that thegetAndroidModule.startListening()
method supposedly returns a Promise, but that I, on the consumer side, have no way tocatch
errors that may be thrown from that Promise. I suspect this is why the error goes uncaught.Maybe the code should be modified to either handle the potential rejection internally (if it really is innocuous):
You could also bubble it up to the user, but given the fact that the
purchaseUpdatedListener
function already returns an EventEmitter subscription, maybe anerrorCallback
as a second parameter that would be called in the case of an error would work:Though this certainly has its drawbacks as well (mixing three separate async paradigms [events, promises, callback]).
Again, thank you for this module, it's been instrumental in offering subscriptions to users. I'm interested to hear your thoughts on the above.
Environment:
The text was updated successfully, but these errors were encountered: