Back to Intellij Community

RunBlockingInSuspendFunction

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/RunBlockingInSuspendFunction.html

2025.3-rc-2664 B
Original Source

Reports runBlocking calls inside suspend functions.

Using runBlocking within a suspend function blocks the calling thread and defeats the purpose of asynchronous programming.

The quick-fix replaces the runBlocking call with one of the following alternatives, depending on the context:

  • A run call.
  • A withContext call when a specific CoroutineContext is used.
  • Directly inlined code without the runBlocking wrapper.

Example:

suspend fun something() {
  runBlocking {
    code() // The thread is blocked here
  }
}

After the quick-fix is applied:

suspend fun something() {
  code() // Runs asynchronously
}

New in 2025.1