Hey guys. I have some problems with network calls ...
# kotlin-native
i
Hey guys. I have some problems with network calls via ktor on iosTest module in my multiplatform app. I’ve created an issue here: https://github.com/ktorio/ktor/issues/895 But now i’m really confused about this. I’m not sure if it’s ktor problem. Maybe native and coroutines, especially emulator, idk…
What do you think guys? Should i create an issue also in kotlin/native or even in coroutines?
i
@Jonas Bark how can i do this in test? It will just pass with launch and i’il never see the result, or i don’t understand something
j
are you performing real http requests or just mocked ones?
i
real
j
ok, that defeats unit testing purposes (as in fast, locally executable without 3rd party dependencies) but you could play with using a TestCoroutineContext
i
@Jonas Bark ktor is very delicate thing in multiplatform app and i need a fast way to make sure that everything is fine on 3 platforms. So i don’t care about any purposes 😄
j
"delicate"...? so you basically want to test if your ktor updates work?
i
Used translator for this word 😓 I want to test if ktor can make simple get request to one site that i parse in main module
@Jonas Bark “delicate”. i meant can be easily broken
@Jonas Bark TestCoroutineContext? But: Platform and version requirements: JVM
j
why "but"? works perfectly fine on JVM and other platforms as well I guess
i
Everywhere but not on ios😑
j
ok, that sucks did you try making your own CoroutineDispatcher implementation on iOS by using grand central dispatch?
j
yes, or
Copy code
dispatch_async(dispatch_get_main_queue()) {
                block.run()
            }
`
i
Actually iosMain works on this (It uses GlobalScope.launch maybe it matters). But when i use this in iosTest it just freezes without any code. Simple runBlocking(MainDispatcher) {}
s
But when i use this in iosTest it just freezes without any code. Simple runBlocking(MainDispatcher) {}
Then this issue should be reported to kotlinx.coroutines project. Please post your findings to original ktor issue first.
i
For those who interested: Here it is https://github.com/Kotlin/kotlinx.coroutines/issues/952