Hello! I have weird issue with Exposed. If code in...
# exposed
r
Hello! I have weird issue with Exposed. If code inside newSuspendedTransactions uses any other suspend function and throws error then all code inside transaction is three times (?) and error is lost. Instead I receive new error "org.postgresql.util.PSQLException: This connection has been closed". Simple example:
Copy code
object NotExistingTable : IntIdTable("some_table")

suspend fun errorExample() {
    try {
        newSuspendedTransaction {
            println("Called!")
            delay(200)
            NotExistingTable.selectAll().forEach { println(it) }
        }
    } catch (e: Exception) {
        e.printStackTrace()
    }
}
Running above code prints: Called! Called! Called! org.jetbrains.exposed.exceptions.ExposedSQLException: org.postgresql.util.PSQLException: This connection has been closed. What is interesing, when I remove delay call (to simplify when I don't use any other suspend function inside newSuspendedTransaction) then it still calls code 3 times but erros is now correct: Called! Called! Called! org.jetbrains.exposed.exceptions.ExposedSQLException: org.postgresql.util.PSQLException: ERROR: relation "some_table" does not exist Any ideas? What am I doing wrong? We are currently using Exposed 0.46.0. Coroutine scope used in example comes from Ktor routing.
c
Hi @Rafał Kuźmiński I saw your YT ticket EXPOSED-408, so I've commented with an answer there.