Store
Store copied to clipboard
[BUG] Calling 'fresh' under heavy load causes the upstream to close unexpectedly
Describe the bug Occasionally, the 'main stream' closes unexpectedly.
To Reproduce Steps to reproduce the behavior:
val scope = CoroutineScope(Dispatchers.Default)
val store = StoreBuilder.from<Int, String>(Fetcher.of { key ->
delay(10) //simulate long network request
"$key :: " + Random.nextInt()
}).build()
scope.launch {
store.stream(StoreReadRequest.cached(1, false)) //main stream
.onCompletion {
println("Unexpected !!!" + it)
}
.collect {
println("result" + it)
}
}
(1 .. 50).onEach {
scope.launch {
while (isActive) {
store.stream(StoreReadRequest.fresh(1))
.filterNot { it is StoreReadResponse.Loading }
.firstOrNull()
delay(150)
}
}
}
- after while, the 'main stream' is completed unexpectedly
- behavior is same when Store.fresh is called
Expected behavior Calling 'fresh' does not cause the 'main stream' to close
Smartphone (please complete the following information):
- Device: all
- OS: all
- Store Version 4., 5.