Has anyone had (DSL) queries hang forever in a kto...
# exposed
m
Has anyone had (DSL) queries hang forever in a ktor route? Im using R2DBC and for some reason all of the queries i make that work just fine when not run from a ktor context (e.g. in a playground main function) but when i call them from a ktor route they hang forever and never return a result Example code is pretty boilerplate but this call never returns but only when running in a ktor route
Copy code
val versions =
  suspendTransaction {
    Applications
      .selectAll()
      .toList()
  }
Update, figured out the fix. Turns out it has something to do with not passing a dispatcher to
suspendTransaction
, so doing
suspendTransaction(<http://Dispatchers.IO|Dispatchers.IO>)
instead fixes it. Does this mean suspend transaction isn't main safe and is blocking the caller thread? This feels a bit counterintuitive to me and isn't documented anywhere. Shouldn't the suspend function handle main safety internally rather than blocking the parent thread?