Closed volkert-fastned closed 8 months ago
Here is the entire example project that reproduces the issue, if that helps:
What I also noticed with that same version upgrade (to version 3.5.3
) was that suddenly, tests started to fail with the same exception, requiring me to add something like this to get them to work again:
@AfterEach
fun tearDown() {
stopKoin()
}
I saw some documentation referring to this, but it's still weird that it was never necessary (not even in 3.5.1
) until I tried upgrading to version 3.5.3
. It seems related to this issue, so I'm mentioning this here as well.
Any news on this? I'm concerned that such a behavioral change in a patch update might also manifest itself at runtime somehow.
Thanks for all your feedback and content. Did you check to use KoinIsolated
plugin instead of normal Koin
plugin?
Here is some doc: https://insert-koin.io/docs/reference/koin-ktor/ktor-isolated
It would help run instances isolated
@arnaudgiuliani I can confirm that using KoinIsolated
solved all the issues I had with Koin
in my ktor
tests, thanks for the tip!
cool :)
@arnaudgiuliani Thanks for the suggestion, I'll look into it. However, my primary concern that led me to open this issue in the first place was the fact that there is compatibility breakage between 3.5.1
and 3.5.3
. Was this an exceptional occurrence, or can we expect such breakage to occur more often with future patch-level version updates?
It worked fine without KoinIsolated
in 3.5.1
, but not in 3.5.3
.
Sorry if I'm being a bit nit-picky about it. But the way how version numbers (with an implied SemVer structure) are updated does raise certain expectations in terms of stability of behavior. I mean: if this breaks, what else might break, especially at run-time? Thanks.
Sorry, I didn't read your sorry for the break
answer in issue https://github.com/InsertKoinIO/koin/issues/1750#issuecomment-1908150608 until just now. From that, I take it that this was an unintended breaking patch change.
Thanks. And please understand that I absolutely appreciate your hard work on this important project. 🙂
Sure; It was an attempt to isolate context from Ktor perspective, but it was breaking a lot. I should have tested feedback with RC releases. It should be as breaking in next versions.
@arnaudgiuliani What if I want to continue sharing the same Koin context between multiple embeddedServer
instances in the same Ktor application, when using Koin version 3.5.3
and onwards? I don't want separate singleton instances in different contexts, since that would be a waste of resources. Thanks.
@arnaudgiuliani Oh wait. If I pass the same Koin module with singletons to different isolated Koin contexts, will those separate Koin contexts share the same singleton instances?
@arnaudgiuliani Oh wait. If I pass the same Koin module with singletons to different isolated Koin contexts, will those separate Koin contexts share the same singleton instances?
I answered my own question here. TL;DR: yes, singletons will remain singletons (and thus will not have duplicate instances), even between isolated Koin contexts. ✅
ok good :)
Describe the bug Right up until version
3.5.1
ofkoin-ktor
, it was never a problem to install Koin in multipleembeddedServer
instances in a multi-server Ktor application. But since version3.5.3
, this results in aKoinAppAlreadyStartedException
.To Reproduce Steps to reproduce the behavior:
embeddedServer
instances.wait
set totrue
in the.start()
function3.5.1
ofkoin-ktor
3.5.3
ofkoin-ktor
Expected behavior The application should start up and run fine with either version, since a patch-level version update should not break compatibility. What actually happens is that this only runs well with version 3.5.1, but with version 3.5.3, the following exception is thrown:
Koin module and version:
koin-ktor:3.5.3
Snippet or Sample project to help reproduce
Below is an example Ktor application that reproduces the issue. the behavior can simply be compared by changing the value of
koinKtorVersion
from3.5.1
to3.5.3
ingradle.properties
. I'll also attach a ZIP file of the entire example project.