Closed raphael-inglin-ergon closed 2 months ago
Hello,
We have the same version of koin: 3.5.6, and we got the same random problem in production, which also caused some requests to fail.
getScopeId() is useful in android, but clashes here with Ktor. Can you ensure there is a clash with the scope id?
HI. As previously mentioned, we cannot reproduce the issue. However the stack trace does clearly indicate some kind of clash.
The exception is thrown in the createScope
function of ScopeRegistry if there is already a Scope with this Id present. Since the RequestScope and its scopeId are automatically created by Koin when a request happens, this indicates that a new RequestScope just happens to have the same scopeId / hashCode as an already active Scope.
The scopeId is generated in KoinScopeComponent
It might also be that old Scopes are not removed correctly in some situations, increasing the likelihood of a collision but this is just speculation from my part.
Generally, hashCode()
does not require two Objects to have different results, so it is plausible that collisions may occur.
would mean that hashcode is too close then? 🤔
I've added UUID scope id to allow wider generation. Should help 👍 See PR https://github.com/InsertKoinIO/koin/pull/1976
Describe the bug Every few days we see exceptions in the logs of our productive system when trying to handling a request, resulting in the request failing.
First, koin fails to initialize the RequestScope:
Then when trying to finish the request, probably as a result of failing to create the scope initially:
It seems that there is a collision in the scopeId, that is automatically generated in
KoinScopeComponent
:To Reproduce We were unable to reproduce the issue. We see the same pattern occur every few days in the logs of our production system, randomly causing a request to fail.
Expected behavior
hashCode()
could be an optionKoin module and version:
Snippet or Sample project to help reproduce See above