Releases: Kotlin/kotlinx.coroutines
Releases Β· Kotlin/kotlinx.coroutines
Release list
1.11.0
Various
- Kotlin was updated to 2.2.20 (#4545).
- Improved the published jar files (#3842, #4599).
- Various documentation improvements, including complete rewrites of structured concurrency and error handling-related KDoc (#4433, #4596).
Breaking changes and deprecations
- Moved
Promise-related functions from JS and Wasm/JS to the newwebtarget. On Wasm/JS, this is a breaking change. Before the change,Promiseon Wasm/JS could work with arbitrary Kotlin types, but now, onlyJsAnysubtypes are accepted (#4563). - Changed handling of coroutine exceptions that can't be propagated on JS and Wasm/JS. B
efore, exceptions were logged, but now, they are reported to the JS runtime (#4451, #4631). - Deprecated using
CoroutineDispatcheras the coroutine context key; now,ContinuationInterceptorhas to be used instead (#4333). - Advanced the deprecation levels on
kotlinx-coroutines-testAPIs (#4604). - Added lint functions that mark passing a
Jobto coroutine builders as deprecated (#4435).
Bug fixes and improvements
- Added a
callsInPlace(EXACTLY_ONCE)contract torunBlockingin code shared between JVM and Native (#4368). - Added a
callsInPlace(EXACTLY_ONCE)contract tosuspendCancellableCoroutine(#4574). - Fixed
flowOnincorrectly handlingThreadContextElementupdates (#4403). - Fixed exceptions in user-supplied
Thread.UncaughtExceptionHandlerinstances causing the internal coroutines machinery to fail (#4516). - Fixed
CoroutineDispatcher.asSchedulerin the RxJava integration not cancelling outstanding work when aWorkergets cancelled, which led to memory leaks in some scenarios (#4615). - Fixed
SharedFlowentering an invalid state when a subscriber and an emitter are cancelled simultaneously (#4583). - Fixed an R8 optimization leading to
shareIn/stateIncoroutines getting garbage-collected (#4646). Thanks, @solevic!
Small additions
- Added
CompletableDeferred.asDeferredfor obtaining a read-onlyDeferredview (#4408). - Added
SharedFlow.asFlowfor obtaining aFlowview with hidden hot flow semantics (#4530). Thanks, @g000sha256! - Added a
StateFlow.collectLatestoverload returningNothingto assist with finding unreachable code (#4454). - Added
ReceiveChannel.consumeTofor consuming aReceiveChannelinto aMutableCollection(#4520). - Added a
StateFlow<T>.onSubscriptionoverload returning aStateFlow<T>, similar toSharedFlow<T>.onSubscriptionreturningSharedFlow<T>(#4275). Thanks, @xit0c! - Added terminal
Flowoperators for collecting aFlowto aMap(#1541).
Changelog relative to version 1.11.0
No changes, only the version is increased.
1.11.0-rc02
Restored binary compatibility with 1.10.2 and older versions on Wasm/JS for usages of Promise-related functions (#4661).
1.11.0-rc01
Various
- Kotlin was updated to 2.2.20 (#4545).
- Improved the published jar files (#3842, #4599).
- Various documentation improvements, including complete rewrites of structured concurrency and error handling-related KDoc (#4433, #4596).
Breaking changes and deprecations
- Moved
Promise-related functions from JS and Wasm/JS to the newwebtarget. On Wasm/JS, this is a breaking change. Before the change,Promiseon Wasm/JS could work with arbitrary Kotlin types, but now, onlyJsAnysubtypes are accepted (#4563). - Changed handling of coroutine exceptions that can't be propagated on JS and Wasm/JS. Before, exceptions were logged, but now, they are reported to the JS runtime (#4451, #4631).
- Deprecated using
CoroutineDispatcheras the coroutine context key; now,ContinuationInterceptorhas to be used instead (#4333). - Advanced the deprecation levels on
kotlinx-coroutines-testAPIs (#4604). - Added lint functions that mark passing a
Jobto coroutine builders as deprecated (#4435).
Bug fixes and improvements
- Added a
callsInPlace(EXACTLY_ONCE)contract torunBlockingin code shared between JVM and Native (#4368). - Added a
callsInPlace(EXACTLY_ONCE)contract tosuspendCancellableCoroutine(#4574). - Fixed
flowOnincorrectly handlingThreadContextElementupdates (#4403). - Fixed exceptions in user-supplied
Thread.UncaughtExceptionHandlerinstances causing the internal coroutines machinery to fail (#4516). - Fixed
CoroutineDispatcher.asSchedulerin the RxJava integration not cancelling outstanding work when aWorkergets cancelled, which led to memory leaks in some scenarios (#4615). - Fixed
SharedFlowentering an invalid state when a subscriber and an emitter are cancelled simultaneously (#4583). - Fixed an R8 optimization leading to
shareIn/stateIncoroutines getting garbage-collected (#4646). Thanks, @solevic!
Small additions
- Added
CompletableDeferred.asDeferredfor obtaining a read-onlyDeferredview (#4408). - Added
SharedFlow.asFlowfor obtaining aFlowview with hidden hot flow semantics (#4530). Thanks, @g000sha256! - Added a
StateFlow.collectLatestoverload returningNothingto assist with finding unreachable code (#4454). - Added
ReceiveChannel.consumeTofor consuming aReceiveChannelinto aMutableCollection(#4520). - Added a
StateFlow<T>.onSubscriptionoverload returning aStateFlow<T>, similar toSharedFlow<T>.onSubscriptionreturningSharedFlow<T>(#4275). Thanks, @xit0c! - Added terminal
Flowoperators for collecting aFlowto aMap(#1541).
1.10.2
- Fixed the
kotlinx-coroutines-debugJAR file including themodule-info.classfile twice, resulting in failures in various tooling (#4314). Thanks, @RyuNen344! - Fixed
Flow.stateInhanging when the scope is cancelled in advance or the flow is empty (#4322). Thanks, @francescotescari! - Improved handling of dispatcher failures in
.limitedParallelism(#4330) and during flow collection (#4272). - Fixed
runBlockingfailing to run its coroutine to completion in some cases if its JVM thread got interrupted (#4399). - Small tweaks, fixes, and documentation improvements.
1.10.1
1.10.0
- Kotlin was updated to 2.1.0 (#4284).
- Introduced
Flow.any,Flow.all, andFlow.none(#4212). Thanks, @CLOVIS-AI! - Reorganized
kotlinx-coroutines-debugandkotlinx-coroutines-corecode to avoid a split package between the two artifacts (#4247). Note that directly referencingkotlinx.coroutines.debug.AgentPremainmust now be replaced withkotlinx.coroutines.debug.internal.AgentPremain. Thanks, @sellmair! - No longer shade byte-buddy in
kotlinx-coroutines-debug, reducing the artifact size and simplifying the build configuration of client code. Thanks, @sellmair! - Fixed
NullPointerExceptionwhen using Java-deserializedkotlinx-coroutines-coreexceptions (#4291). Thanks, @AlexRiedler! - Properly report exceptions thrown by
CoroutineDispatcher.dispatchinstead of raising internal errors (#4091). Thanks, @zuevmaxim! - Fixed a bug that delayed scheduling of a
Dispatchers.DefaultorDispatchers.IOtask after ayield()in rare scenarios (#4248). - Fixed a bug that prevented the
main()coroutine on Wasm/WASI from executing after adelay()call in some scenarios (#4239). - Fixed scheduling of
runBlockingtasks on Kotlin/Native that arrive after therunBlockingblock was exited (#4245). - Fixed some terminal
Flowoperators sometimes resuming without taking cancellation into account (#4254). Thanks, @jxdabc! - Fixed a bug on the JVM that caused coroutine-bound
ThreadLocalvalues not to get cleaned when using non-CoroutineDispatchercontinuation interceptors (#4296). - Small tweaks, fixes, and documentation improvements.
1.9.0
Features
- Wasm/WASI target support (#4064). Thanks, @igoriakovlev!
limitedParallelismnow optionally accepts the name of the dispatcher view for easier debugging (#4023).- No longer initialize
Dispatchers.IOon the JVM when other standard dispatchers are accessed (#4166). Thanks, @metalhead8816! - Introduced the
Flow<T>.chunked(size: Int): Flow<List<T>>operator that groups emitted values into groups of the given size (#1290). - Closeable dispatchers are instances of
AutoCloseablenow (#4123).
Fixes
- Calling
hasNexton aChannel's iterator is idempotent (#4065). Thanks, @gitpaxultek! CoroutineScope()created without an explicit dispatcher usesDispatchers.Defaulton Native (#4074). Thanks, @whyoleg!- Fixed a bug that prevented non-Android
Dispatchers.Mainfrom initializing when the Firebase dependency is used (#3914). - Ensured a more intuitive ordering of tasks in
runBlocking(#4134). - Forbid casting a
MutextoSemaphore(#4176). - Worked around a stack overflow that may occur when calling
asDeferredon aFuturemany times (#4156).
Deprecations and promotions
- Advanced the deprecation levels for
BroadcastChannel-based API (#4197). - Advanced the deprecation levels for the old
kotlinx-coroutines-testAPI (#4198). - Deprecated
Job.cancelFutureOnCompletion(#4173). - Promoted
CoroutineDispatcher.limitedParallelismto stable (#3864). - Promoted
CoroutineStart.ATOMICfromExperimentalCoroutinesApitoDelicateCoroutinesApi(#4169). - Promoted
CancellableContinuation.resumewith anonCancellationlambda to stable, providing extra arguments to the lambda (#4088). - Marked the classes and interfaces that are not supposed to be inherited from with the new
InternalForInheritanceCoroutinesApiopt-in (#3770). - Marked the classes and interfaces inheriting from which is not stable with the new
ExperimentalForInheritanceCoroutinesApiopt-in (#3770).
Other
1.9.0-RC.2
- Advanced the deprecation levels for
BroadcastChannel-based API (#4197). - Advanced the deprecation levels for the old
kotlinx-coroutines-testAPI (#4198). - Promoted
CoroutineStart.ATOMICfromExperimentalCoroutinesApitoDelicateCoroutinesApi(#4169). - Reworked the documentation for
CoroutineStartandChannel-based API (#4147, #4148, #4167). Thanks, @globsterg! - Forbid casting a
MutextoSemaphore(#4176). - Deprecated
Job.cancelFutureOnCompletion(#4156). - Worked around a stack overflow that may occur when calling
asDeferredon aFuturemany times (#4156). - Fixed a bug that disallowed setting a custom
probeCoroutineResumedwhen starting coroutines withUNDISPATCHED(#4162). - No longer initialize
Dispatchers.IOon the JVM when other standard dispatchers are accessed (#4166). Thanks, @metalhead8816! - Small tweaks, fixes, and documentation improvements.
1.9.0-RC
- Kotlin was updated to 2.0 (#4137).
- Introduced the
Flow<T>.chunked(size: Int): Flow<List<T>>operator that groups emitted values into groups of the given size (#1290). - Closeable dispatchers are instances of
AutoCloseablenow (#4123). limitedParallelismnow optionally accepts the name of the dispatcher view for easier debugging (#4023).- Marked the classes and interfaces that are not supposed to be inherited from with the new
InternalForInheritanceCoroutinesApiopt-in (#3770). - Marked the classes and interfaces inheriting from which is not stable with the new
ExperimentalForInheritanceCoroutinesApiopt-in (#3770). - Wasm/WASI target support (#4064). Thanks, @igoriakovlev!
- Promoted
CoroutineDispatcher.limitedParallelismto stable (#3864). - Promoted
CancellableContinuation.resumewith anonCancellationlambda to stable, providing extra arguments to the lambda (#4088). - Ensured a more intuitive ordering of tasks in
runBlocking(#4134). - Simplified the internal implementation of
Job(#4053). - Fixed a bug that prevented non-Android
Dispatchers.Mainfrom initializing when the Firebase dependency is used (#3914). - Calling
hasNexton aChannel's iterator is idempotent (#4065). Thanks, @gitpaxultek! CoroutineScope()created without an explicit dispatcher usesDispatchers.Defaulton Native (#4074). Thanks, @whyoleg!- Small tweaks and documentation fixes.
1.8.1
- Remove the
@ExperimentalTimeannotation from usages ofTimeSource(#4046). Thanks, @hfhbd! - Introduce a workaround for an Android bug that caused an occasional
NullPointerExceptionwhen setting theStateFlowvalue on old Android devices (#3820). - No longer use
kotlin.random.Randomas part ofDispatchers.DefaultandDispatchers.IOinitialization (#4051). Flow.timeoutthrows the exception with which the channel was closed (#4071).- Small tweaks and documentation fixes.