First beta of the 4.3 line: a faster Koin core with no public API change, plus fixes for Ktor request scopes and Compiler Plugin ViewModels. Two behavior changes are flagged below.
⚠️ This is a beta, not a stable release: more 4.3 features are coming in the next betas, and new APIs may still change before 4.3.0. Stay on 4.2.2 for production. Please try it on your project and tell us what you see, especially under load or on Ktor.
Improvements
-
Faster resolution and registration in koin-core: no debug strings built when logging is off, and no index key rebuilt on repeat lookups. On the JVM:
- Warm
get(): 157 ns / 587 B per call, now 26 ns / 56 B. - Registering 3,600 definitions: 927 µs, now 269 µs.
- Scope cascade resolution: 1,510 ns, now 731 ns.
Resolution results are the same as 4.2. Android devices are not measured yet.
- Warm
Bug Fixes
-
Ktor request scope closed for failed and cancelled calls (#2463, #2472): the scope was closed only when a response was sent. Cancelled calls (SSE closed, client gone), streams failing mid-body and failing response hooks kept the scope and its
ApplicationCallalive until the server ran out of memory. The scope now closes at the end of every call; error pages and later response hooks still see it open.⚠️ Behavior change: with
HttpRequestLifecycle(cancelCallOnClose = true)and a WebSocket session, the request scope now closes on cancellation, before the session handler'sfinally. It was never closed before. -
Ktor auto-reload no longer closes the new Koin (#2461, #2468): with Ktor 3.5, the old application's stop event closed the new application's Koin.
-
ParametersHolder.setacceptsnull(#2476), likeparametersOf. -
Compiler Plugin ViewModels no longer collide across modules (#2474): every plugin ViewModel was bound to
ViewModel, so ViewModels in two or more modules failed at start understrictOverride(), or logged override warnings. They're now registered under their own type only, likeviewModel { }.⚠️ Behavior change:
get<ViewModel>()andgetAll<ViewModel>()no longer return Compiler Plugin ViewModels. Resolve a ViewModel by its own type.ViewModels extending a shared abstract class or interface still collide on that supertype: use
@KoinViewModel(binds = [])until Koin Compiler Plugin 1.3.0.
Thanks 🙏
- @inemtsev and @nathanfallet: Ktor request scope reports and fixes (#2464, #2473)
- @arimu1: Ktor auto-reload fix (#2468)
- @Alox1d:
ParametersHolder.setwithnull(#2476) - @jg-hot, @mottljan and @ChristophyBarth: reports, repros and analysis
- @kchinburarat, @xabixa and @aszorenyi: for backing the Ktor leak fix
Your feedback is welcome!