Skip to content

Upgrading org.jetbrains.kotlinx:kotlinx-coroutines-core 0.30 to 1

Breaking0.30.2-eap13 → 1.11.0Breaking43Platform3Deprecated27New127Changed203Fixed168Other36

BreakingUpgrade verdict

40 breaking changes and 3 platform requirement changes.

  • Removes support for the old Kotlin/Native memory model.
  • Artificial stackframes in stacktrace recovery no longer contain the \b symbol and are now navigable in the IDE with proper documentation.
  • Exceptions from the future builder during cancellation races are no longer sent to the global handler.
  • If a Main dispatcher exists, delay and withTimeout use its clock by default.
Top 5 of 70 that need code or config changes

Adds org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm 1.11.0.

Drops org.jetbrains.kotlin:kotlin-stdlib, org.jetbrains.kotlinx:kotlinx-coroutines-core-common.

Installs 3 packages in all (was 4).

Breaking40
Removes support for the old Kotlin/Native memory model.
Artificial stackframes in stacktrace recovery no longer contain the \b symbol and are now navigable in the IDE with proper documentation.
When racing with cancellation, the future builder no longer reports unhandled exceptions into the global CoroutineExceptionHandler.
futureCoroutineExceptionHandler
Dispatchers.Main is now the default time source for delay and withTimeout when present.
Dispatchers.MaindelaywithTimeout
Source-breaking: extension collect no longer resolves with a non-in-place argument of a functional type.
collect
Makes DisposableHandle a fun interface and removes the corresponding inline extension.
DisposableHandleFlowCollector
Removes support for the deprecated CommonPool.
CommonPool
Removes atomic cancellation in channels; all channel operations and corresponding Flow operators are now cancellable in a non-atomic way.
Flow
Flow.singleOrNull is aligned with the standard library and no longer throws IllegalStateException on multiple values.
Flow.singleOrNullIllegalStateException
Removes kotlinx-coroutines-core-common and kotlinx-coroutines-core-native artifacts in the new HMPP publication scheme.
kotlinx-coroutines-core-commonkotlinx-coroutines-core-native
flow prohibits emissions from non-scoped coroutines by default and recommends channelFlow instead.
flowchannelFlow
Flow can no longer be implemented directly; AbstractFlow is introduced for extension.
FlowAbstractFlow
Reworks flowViaChannel so the block parameter is no longer suspending, provides a CoroutineScope receiver and allows a conflated channel.
flowViaChannelCoroutineScope
Renames the Flow purity property to context preservation and makes it more restrictive.
Flow
Makes major improvements to cancellation machinery and exception delivery consistency, and completely removes cancel with a custom exception.
Moves Promise-related functions from JS and Wasm/JS to the new web target; on Wasm/JS only JsAny subtypes are now accepted.
PromiseJsAny
Changes handling of coroutine exceptions that cannot be propagated on JS and Wasm/JS to report them to the JS runtime instead of logging.
Adds new generic upper bounds to the reactive integration API as dictated by the language since 1.8.0.
Merges kotlinx-coroutines-core and kotlinx-coroutines-jdk8 artifacts into a single artifact.
kotlinx-coroutines-corekotlinx-coroutines-jdk8
CoroutineContext.isActive now returns true for contexts without any job in them.
CoroutineContext.isActive
Removes obsolete TestCoroutineContext, fixing the kotlinx-coroutines-test JPMS package split between core and test modules.
TestCoroutineContext
Makes CoroutineDispatcher.releaseInterceptedContinuation a final method.
CoroutineDispatcher.releaseInterceptedContinuation
Major channels API rework deprecates offer, poll, and sendBlocking, removes internal receiveCatching and onReceiveCatching, and removes SendChannel.isFull.
offerpollsendBlockingreceiveCatchingonReceiveCatchingreceiveOrNullonReceiveOrNullSendChannel.isFull
Renames internal class TimeSource to SchedulerTimeSource to prevent wildcard import issues.
TimeSourceSchedulerTimeSource
SharingStarted is now a fun interface.
SharingStarted
When a CoroutineDispatcher throws RejectedExecutionException, the current Job is cancelled and its execution is scheduled to Dispatchers.IO.
CoroutineDispatcherRejectedExecutionExceptionJobDispatchers.IO
CancellableContinuation.invokeOnCancellation is now invoked when the continuation is cancelled while its resume has been dispatched.
CancellableContinuation.invokeOnCancellation
Replaces scanReduce with runningReduce to be consistent with the Kotlin standard library.
scanReducerunningReduce
Changes Flow.onCompletion behaviour to align with invokeOnCompletion, passing CancellationException to its cause parameter.
Flow.onCompletioninvokeOnCompletionCancellationException
Changes suspendCancellableCoroutine so cancellation is established before invoking the passed block argument.
suspendCancellableCoroutine
Throws NoSuchElementException instead of UnsupportedOperationException for empty Flow in reduce operator (#1659).
NoSuchElementExceptionUnsupportedOperationExceptionFlowreduce
Reactive integration builders become top-level functions and reject a Job in their context.
CoroutineScopeJob
Reworks the context preservation invariant (#1210).
Replaces flatMap, merge and concatenate with flattenConcat, flattenMerge, flatMapConcat and flatMapMerge.
flatMapmergeconcatenateflattenConcatflattenMergeflatMapConcatflatMapMerge
Resuming a CancellableContinuation that is already in its final state now throws IllegalStateException (#901).
CancellableContinuation
Restricts the rxFlowable generic parameter with Any.
rxFlowable
Removes deprecated API or marks it as internal.
Moves AgentPremain to kotlinx.coroutines.debug.internal to avoid a split package.
kotlinx.coroutines.debug.AgentPremainkotlinx.coroutines.debug.internal.AgentPremain
The kotlinx-coroutines-test API is completely reworked to address consistency, structured concurrency and correctness issues.
Marks experimental and internal coroutine API with kotlin.experimental.Experimental, requiring explicit opt-in.
kotlin.experimental.Experimental@ExperimentalCoroutinesApi@InternalCoroutinesApi
Platform3
Kotlin/Native new memory model is supported in regular builds conditionally on kotlin.native.binary.memoryModel being enabled.
kotlin.native.binary.memoryModel
JDK 1.6 is no longer required for building the project.
Adds watchosX64 target support for Kotlin/Native.
watchosX64
Deprecated27
Deprecates using CoroutineDispatcher as the coroutine context key; use ContinuationInterceptor instead.
CoroutineDispatcherContinuationInterceptor
Advances the deprecation levels on kotlinx-coroutines-test APIs.
kotlinx-coroutines-test
Adds lint functions that mark passing a Job to coroutine builders as deprecated.
Job
Advances the deprecation levels for BroadcastChannel-based API.
BroadcastChannel
Advances the deprecation levels for the old kotlinx-coroutines-test API.
kotlinx-coroutines-test
Deprecates Job.cancelFutureOnCompletion.
Job.cancelFutureOnCompletion
Deprecates Job.cancelFutureOnCompletion.
Job.cancelFutureOnCompletion
Deprecates the configuration of quiescence timeouts, replaced by the runTest timeout parameter.
runTest
Deprecates BroadcastChannel and all the corresponding API.
BroadcastChannel
The old kotlinx-coroutines-test API is deprecated for removal.
Mutex.onLock is deprecated for removal.
Mutex.onLock
Raises the deprecation level of all previously deprecated signatures.
Deprecates an obsolete method on the internal Delay interface.
Delay
Marks BroadcastChannel and ConflatedBroadcastChannel as ObsoleteCoroutinesApi in favor of SharedFlow and StateFlow.
BroadcastChannelConflatedBroadcastChannelObsoleteCoroutinesApiSharedFlowStateFlow
Deprecates misleading awaitSingleOr* functions on the Publisher type.
awaitSingleOr*Publisher
Deprecates MaybeSource.await in favor of awaitSingle and adds lint functions for Mono to prevent ambiguous Publisher usages.
MaybeSource.awaitawaitSingleMonoPublisher
Obsolete reactive API is deprecated.
Deprecation level for API deprecated in 1.3.0 is increased.
Deprecates combineLatest in favor of combine.
combineLatestcombine
Deprecates switchMap and introduces flatMapLatest, mapLatest and transformLatest.
switchMapflatMapLatestmapLatesttransformLatest
Deprecates delayEach and delayFlow.
delayEachdelayFlow
Deprecates flowWith and flowViaChannel.
flowWithflowViaChannel
Deprecates all channel operators prone to coroutine leaks in favor of Flow.
Flow
Deprecates consumerEach for removal on Publisher, ObservableSource and MaybeSource, introducing the collect extension instead.
consumerEachcollectPublisherObservableSourceMaybeSource
Deprecates SendChannel.isFull and ReceiveChannel.isEmpty.
SendChannel.isFullReceiveChannel.isEmpty
Marks ReceiveChannel.receiveOrNull as obsolete and deprecated.
ReceiveChannel.receiveOrNull
Deprecates Job.cancel(cause) and ReceiveChannel.cancel(cause); cancel() now returns Unit.
Job.cancel(cause)ReceiveChannel.cancel(cause)cancel()