Skip to content

Commit f1d7d13

Browse files
committed
Improve CancellationException handling.
Kotlin/kotlinx.coroutines#3658 (comment)
1 parent c95fa1f commit f1d7d13

File tree

1 file changed

+3
-1
lines changed
  • kmp/feed-sync/runtime/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/sync

1 file changed

+3
-1
lines changed

kmp/feed-sync/runtime/src/commonMain/kotlin/io/github/reactivecircus/kstreamlined/kmp/feed/sync/FeedSyncEngineImpl.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import kotlinx.coroutines.Dispatchers
1919
import kotlinx.coroutines.IO
2020
import kotlinx.coroutines.channels.Channel
2121
import kotlinx.coroutines.coroutineScope
22+
import kotlinx.coroutines.currentCoroutineContext
23+
import kotlinx.coroutines.ensureActive
2224
import kotlinx.coroutines.flow.MutableStateFlow
2325
import kotlinx.coroutines.flow.StateFlow
2426
import kotlinx.coroutines.flow.filter
@@ -77,7 +79,7 @@ public class FeedSyncEngineImpl(
7779
}
7880
syncState.value = SyncState.Idle
7981
}.onFailure {
80-
if (it is CancellationException) throw it
82+
if (it is CancellationException) currentCoroutineContext().ensureActive()
8183
Logger.w("Sync failed", it)
8284
syncState.value = SyncState.OutOfSync
8385
}

0 commit comments

Comments
 (0)