Maybe I am not fully understanding the code in DataSource . reuseInflight but if job gets cancelled before the line with launch gets called, then job is stuck in a cancelled state and subsequent calls to get() immediately fail. My app seemed to be getting into this situation and couldn't recover.
Yes, this looks like a sensible solution and probably should have always been written like this! I've created a unit test that shows this solution works (and breaks on the original code)
Maybe I am not fully understanding the code in
DataSource . reuseInflight
but ifjob
gets cancelled before the line withlaunch
gets called, thenjob
is stuck in a cancelled state and subsequent calls toget()
immediately fail. My app seemed to be getting into this situation and couldn't recover.For reference:
Adding
job?.invokeOnCompletion { job = null }
seems to fix the issue I was experiencing: