Jens Suhr
10/05/2020, 7:38 AMevalOn
(with any pool) seems to cause a deadlock in the IntelliJ debugger. This happens with both the whole application in debug mode and a single function in a test. Is there a wrapper or entry point I missed in the docs?simon.vergauwen
10/05/2020, 10:59 AMJens Suhr
10/05/2020, 11:23 AMsuspend fun readImage(path: String): Either<Throwable, ByteArray> = evalOn(IOPool) {
Either.catch {
Files.readAllBytes(Path.of(path))
}
}
with a test (using kotest) like
class ReadImageTest : StringSpec() {
init {
"should read an existing image file" {
readImage("logos/logo.png") shouldBeRight { bytes ->
bytes.size shouldBeGreaterThan 1000
}
}
"should return an error for a non-existing file" {
readImage("logos/foo.png").shouldBeLeft()
}
}
}
Looks like two stack frames have each other as callerFrame
in
private tailrec fun CoroutineStackFrame.owner(): CoroutineOwner<*>? =
if (this is CoroutineOwner<*>) this else callerFrame?.owner()
simon.vergauwen
10/06/2020, 9:33 AMprivate tailrec fun CoroutineStackFrame.owner(): CoroutineOwner<*>? =
if (this is CoroutineOwner<*>) this else callerFrame?.owner()
Where did you find following snippet? It's not from within Arrow Fx Coroutines?simon.vergauwen
10/06/2020, 9:46 AM0.11.0
and Kotest 4.2.6
.
I only changed Path.of
to Paths.get
since Path.of
wasn't compiling for me with kotlin-std:1.4.10
.
My gradle looked like the following:
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation "io.arrow-kt:arrow-fx-coroutines:0.11.0"
testImplementation 'io.kotest:kotest-runner-junit5:4.2.6'
testImplementation 'io.kotest:kotest-assertions-core:4.2.6'
testImplementation 'io.kotest:kotest-property:4.2.6'
testImplementation 'io.kotest:kotest-assertions-arrow:4.2.6'
I'm not sure how you were testing the files, since you didn't include that part in your snippet. So I saw the first test fail, with Left(java.nio.file.NoSuchFileException: logos/logo.png) is of type arrow.core.Either.Left but expected arrow.core.Either.Right
.
The second test passed as expected since foo.png
is also not found.Jens Suhr
10/06/2020, 11:39 AMsimon.vergauwen
10/06/2020, 11:47 AMCoroutineStackFrame
contract in the exact same way as KotlinX Coroutines, and as described by the Kotlin Std. I am not 100% sure what goes in when you debug, I think there is even some special support in IDEA for debugging coroutines.
The snippet you shared earlier relating to CoroutineStackFrame
doesn't come from Arrow Fx Coroutines, and it looks like it might result in an eternal loop. Could that be the culprit?Jens Suhr
10/06/2020, 11:50 AMCouroutineStackFrame
Jens Suhr
10/06/2020, 12:00 PMJens Suhr
10/06/2020, 12:00 PMJens Suhr
10/06/2020, 12:01 PMsimon.vergauwen
10/06/2020, 12:03 PMKristian
10/12/2020, 12:10 PMsimon.vergauwen
11/30/2020, 9:08 AMJens Suhr
11/30/2020, 9:26 AM