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

gildor

11/14/2018, 7:43 AM
@elizarov And what is recommended way to handle it?
tryResumeWithException
? I understand this behaviour, avoid exception swallowing, but in this particular case looks that this is the only valid option
e

elizarov

11/14/2018, 8:17 AM
I’m writing an issue about it with the detailed description and available workarounds. Hold on.
g

gildor

11/14/2018, 8:25 AM
🙏
cc @Tolriq
g

gildor

11/14/2018, 9:12 AM
So, before introduction of new API, it’s impossible to publish library with fix without marking all the APIs without
InternalCoroutinesApi
t

Tolriq

11/14/2018, 9:18 AM
Thanks a lot for the answer and complete description, will investigate and use one of the hack for now as it's hard to give up on coroutines they are so great 🙂
g

gildor

11/14/2018, 9:23 AM
One more question, wouldn’t be this exception easy to debug if stack-trace would have
Continuation.resume()
and error message that cause this problem. Looks that this already works like that for cases when you call resume more than one time Because now exception just re-thrown without actual reference to Continuation.resume
t

Tolriq

11/14/2018, 9:28 AM
I too agree on that last one, I had no idea where to look and went to OkHttp guys 🙂
t

Tolriq

11/14/2018, 10:11 AM
just a quick question about UseExperimental, IDE tells mes that I should add -X experimental compilation flag but it seems to compile without it. Anything I should add in the gradle kotlin dsl files for Android ?
g

gildor

11/14/2018, 10:12 AM
You can suppress it using compiler flag, if you want
t

Tolriq

11/14/2018, 10:16 AM
Ok so it's just a warning. I'll keep it to remind me of returning to that code at a later point. Thanks.
@elizarov Looking at workaround 1 as for this case I don't really care about exception in that case. Reading at documentation of the privates API do I still need to keep line 2? As it seems the
continuation.tryResumeWithException(exception)?.let { continuation.completeResume(it) }
handle everything no?
e

elizarov

11/14/2018, 10:19 AM
Yes. You don’t need LINE(2) in this case. Corrected
t

Tolriq

11/14/2018, 10:23 AM
Ok perfect thanks a lot was really hard to understand, will go with that for now with my beta users. I hope https://github.com/Kotlin/kotlinx.coroutines/issues/833 can make it to 1.0.2 as I started to become mad trying to understand how that crash could happen while being catched.
So after a few days in beta I can confirm that this was the source of the crashes and that the workaround 1 does work perfectly. Thanks again for the help, could not have found that alone.
@elizarov Bad news I went to prod and the issue is still present 😞 I'm using this code: https://gist.github.com/Tolriq/dcbdc62c0e29d3b321034e990c3c85ce (Your workaround 1).
6 Views