RevenueCat / purchases-android

Android in-app purchases and subscriptions made easy.
https://www.revenuecat.com/
MIT License
234 stars 44 forks source link

Possible bug ? #1765

Open anmol-tray opened 1 week ago

anmol-tray commented 1 week ago

https://github.com/RevenueCat/purchases-android/blob/36ddd195619d39653d40c877d56ac1cefc3a0e92/purchases/src/defaults/kotlin/com/revenuecat/purchases/coroutinesExtensions.kt#L24

it should be suspendCancellableCoroutine instead of suspendCoroutine

RCGitBot commented 1 week ago

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

rglanz-rc commented 4 days ago

Hi @anmol-tray could you give some more context on why you believe this is a bug? It seems that the cancellation handling of suspendCancellableCoroutine could be an enhancement, but are you running into problems with this code as is?

oiatomic commented 4 days ago

Hi @anmol-tray could you give some more context on why you believe this is a bug? It seems that the cancellation handling of suspendCancellableCoroutine could be an enhancement, but are you running into problems with this code as is?

Yes because when we cancel a coroutine using a job.cancel the suspendCoroutine doesn't cancel the revenueCat call.. but wrapping the normal non suspend function for get current customer in my own suspendCancellableCoroutine cancells the coroutine.

Ref:

https://github.com/android/codelab-kotlin-coroutines/issues/8

https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/suspend-cancellable-coroutine.html

It's important that the coroutine cancels properly with cancellation exception

If you think it's not an issue please feel free to close this issue.

Thanks!