https://kotlinlang.org logo
#coroutines
Title
# coroutines
p

Patrik Åkerfeldt

06/23/2021, 2:32 PM
I'm trying to make firebase-admin calls coroutine-friendly. The api call returns an ApiFuture. I want to wrap that in a suspend function with a set timeout. The attached code is my approach to it but the timeout never seem to trigger if the third party request stalls for whatever reason. I'm trying to figure out if this is at all a sane approach or if I'm doing something wrong. Can I expect the
withTimeout
to trigger an exception after 5 seconds of no response?
a

Adam Powell

06/23/2021, 2:36 PM
try
suspendCancellableCoroutine
instead of
suspendCoroutine
p

Patrik Åkerfeldt

06/23/2021, 2:38 PM
Tests passed: 1
Thanks a bunch!
👍 1
6 Views