Hi, i've got som problem with coroutines (1.8.0-RC...
# compose-web
m
Hi, i've got som problem with coroutines (1.8.0-RC2) I am running compose application on Android, iOS and WASM. Provided code acts differently on WASM than expected.
Copy code
App() {
   LaunchedEffect(Unit) {
      fetchUsers()
   }
}
fetchUsers() is a suspend function that feteches users fro the backend. On Android and iOS the function is invoked and users are listed in the console. On WASM there is infinite loop that after every
fetchUsers()
invocation reloades the whole page
o
Do you have the same issue with coroutines 1.8.0-RC?
m
I will check with
1.8.0-RC
give me a 2min
same situation with
1.8.0-rc
imho its not corutines its something with compose
fetchUsers
is provided via
presentation
presentation is provided via simple service locator
Copy code
objec DI {
   val presentationFactory by lazy {
      RealPresentationFactory()
   }
}
so the whole code looks like that:
Copy code
App() {
   val presentation = remember { DI.presentationFactory.createAppPresentation() }   

   LaunchedEffect(Unit) {
      presentation.getUsers()
   }
}
o
Let's try to eliminate it's not coroutines related could you please check:
Copy code
fun main() {
    MainScope().launch {
        fetchUsers()
        println("Done")
    }
}
_
m
I've did:
Copy code
LaunchedEffect(Unit) {
  test()
}
Copy code
private suspend fun test() {
   (1..10).forEach {
      deleay(5000)
      printLn(it)
   }
}
and it's working ok
o
good. There is something specific in fetchUsers() then
m
same with the MainScope() - infinite loop
i will go deeper into the function
o
okay. Then it's probably coroutines related issue
m
it's problem with KTOR client
👍 1
Copy code
LaunchedEffect() {
   presentaton.fetchUsers()
}

...

suspend fun fetchUsers() {
  delay(5000)
  return listOf(User, User)
}
Works OK
Copy code
LaunchedEffect() {
   <http://client.post|client.post>("/login") ...
}

...

client = HttpClient { ... }
Loop
if u interested i've created an issue about this case https://youtrack.jetbrains.com/issue/KTOR-6616
🙏 1