Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.concurrency

Avoid block_on inside async functions

Calling block_on from async code can deadlock the runtime.

#Metadata

Rule ID
rust.correctness.block-on-in-async
Severity
high
Confidence
0.85
Languages
rust
Presets
strict
Stability
stable
Applies to
block
Tags
concurrency, correctness, rules-catalog, rust

#Why it matters

`Handle::current().block_on`, `Runtime::block_on`, and `futures::executor::block_on` block the async executor thread and can deadlock when invoked from `async fn`.

#Remediation

Await the future directly or run blocking work on a dedicated runtime thread.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/rust/rust.correctness.block-on-in-async.rule.yaml.