ArioAtlas / react-native-cafe-bazaar

In-App billing for Cafe Bazaar (local android market)
MIT License
26 stars 9 forks source link

Can't start async operation (refresh inventory) #7

Closed barghi closed 5 years ago

barghi commented 6 years ago

we have seen this issue too in appCenter Analytics:

ava.lang.IllegalStateException: Can't start async operation (refresh inventory) because another async operation(refresh inventory) is in progress.

we use await for all of our inventory functions but we have been getting 55 exceptions since 4 days ago

const inventory = JSON.parse(await CafeBazaar.loadInventory(res.items.map(item => item.sku)));
console.log('Inventory: ', inventory);
const ownedItems = JSON.parse(await CafeBazaar.loadOwnedItems());
console.log('OwnedItems: ', ownedItems);

this is stack trace

com.contoriel.cafebazaar.util.IabHelper.flagStartAsync
IabHelper.java - line 819
java.lang.IllegalStateException: Can't start async operation (refresh inventory) because another async operation(refresh inventory) is in progress.
com.contoriel.cafebazaar.util.IabHelper.flagStartAsync IabHelper.java:819
com.contoriel.cafebazaar.util.IabHelper.queryInventoryAsync IabHelper.java:611
com.contoriel.cafebazaar.util.IabHelper.queryInventoryAsync IabHelper.java:639
com.contoriel.cafebazaar.CafeBazaar.loadOwnedItems CafeBazaar.java:144
java.lang.reflect.Method.invokeNative Method.java
java.lang.reflect.Method.invoke Method.java:511
com.facebook.react.bridge.JavaMethodWrapper.invoke JavaMethodWrapper.java:374
com.facebook.react.bridge.JavaModuleWrapper.invoke JavaModuleWrapper.java:162
com.facebook.react.bridge.queue.NativeRunnable.run NativeRunnable.java
android.os.Handler.handleCallback Handler.java:615
android.os.Handler.dispatchMessage Handler.java:92
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage MessageQueueThreadHandler.java:31
android.os.Looper.loop Looper.java:153
com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run MessageQueueThreadImpl.java:194
java.lang.Thread.run Thread.java:856
ArioAtlas commented 6 years ago

Hi @barghi, thanks for reporting. we use just one thread for each request. so, you can not run multiple async operations at the same time. we will work around this matter for next update. meanwhile, you need to keep track of your Cafebazaar async requests and run one async request each time.

arashmilani commented 5 years ago

I'm closing this issue. feel free to reopen it if needed.