Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Calling 'fresh' under heavy load causes the upstream to close unexpectedly #636

Closed
lukisk opened this issue May 21, 2024 · 0 comments · Fixed by #637
Closed

[BUG] Calling 'fresh' under heavy load causes the upstream to close unexpectedly #636

lukisk opened this issue May 21, 2024 · 0 comments · Fixed by #637
Labels
bug Something isn't working

Comments

@lukisk
Copy link
Contributor

lukisk commented May 21, 2024

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.
@lukisk lukisk added the bug Something isn't working label May 21, 2024
@lukisk lukisk mentioned this issue May 21, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant