arrow-kt / arrow

Λrrow - Functional companion to Kotlin's Standard Library
http://arrow-kt.io
Other
6.13k stars 442 forks source link

Saga with raise inside SagaActionStep don't rollback #3458

Open outlndrr opened 2 months ago

outlndrr commented 2 months ago

Hi, there is a problem if raise happened inside SagaActionStep then saga don't rollback action, but return Either.Left. Example code:

suspend fun main() {
    // perform the transaction
    val result = either {
        saga {
            saga({
                raise("failed")
                println("Action A")
            }) { println("Rollback A") }
        }.transact()
    }
    println(result)
}

Arrow version: 1.2.4

kyay10 commented 2 months ago

What printout are you getting, and what's your expected output?

outlndrr commented 2 months ago

What printout are you getting, and what's your expected output?

It printed Either.Left and that was all. I expected it to run a rollback and print "Rollback A" and return Either.Left.

nomisRev commented 2 months ago

@outlndrr that should indeed result in rolling back the action. Thank you for reporting this issue, I think this is fixed on 2.0.0 but might be missing a test case. So leaving this issue open!