Skip to content

[Bug]: CancellationExceptions are not always rethrown #889

Closed
@sproctor

Description

@sproctor

General Info

  • I checked for similar bug report
  • I am using the latest version
  • I checked the troubleshooting page for similar problems

Version(s)

3.1.3

Kotlin Target(s) and their respective versions

All

What happened? (include your code)

I'm getting logged exceptions being handled from cancelled coroutines. Any try/catch containing a suspend call should check for and rethrow CancellationExceptions.

My code triggering this:

coroutineScope {
  val channel = supabase.realtime.channel("db-changes")
  channel.postgresChangeFlow<PostgresAction>(schema = "public") {
              ...
  }
  .onEach { ... }
  .launchIn(this)
  channel.subscribe(true)
  try {
    awaitCancellation()
  } finally {
    withContext(NonCancellable) {
      channel.unsubscribe()
      supabase.realtime.removeChannel(channel)
    }
  }
}

Steps To Reproduce (optional)

No response

Relevant log output (optional)

Unfortunately, I'm not getting the full stacktrace in my logs.

ChildCancelledException: Child of the scoped flow was cancelled

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions