asyncruntimedeadlock

block_on inside an async fn

Calling Runtime::block_on or futures::executor::block_on from already-async code.

Why this looks tempting

It bridges a sync API into an async caller in one line — and it compiles.

Why wrong

Tokio's worker threads cannot park themselves; calling block_on on the runtime that is currently driving you panics or deadlocks. Even on multi-threaded runtimes the worker is now wasted — you've turned an async task into a blocked thread.

Fix

If the inner future is already async, just .await it. If you must call sync work, hand it to spawn_blocking. Keep block_on for the program's outermost sync entry point only — main, a test harness, an FFI callback.

Canonical alternative

async-patterns/select-join