# \`.await\` in a #\[query\] function

**URL:** <https://forum.dfinity.org/t/await-in-a-query-function/62102>\
**Category:** Rust\
**Created:** [January 2, 2026, 1:55pm UTC](https://forum.dfinity.org/t/await-in-a-query-function/62102 "2026-01-02T13:55:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranile](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ranile/32/34430_2.png) [@ranile](https://forum.dfinity.org/u/ranile)\
**Post date:** [January 2, 2026, 1:55pm UTC](https://forum.dfinity.org/t/await-in-a-query-function/62102/1 "2026-01-02T13:55:59Z")

</div>

I’m integrating Turso database in my canister and it requires database calls to be async

```rust
#[query]
async fn query_something() -> Vec<String> {
    with_connection(async |c| {
        Something::query_all(&c).await
    })
    .await
    .expect("failed to read all")
}

```

This fails with:

```auto
Canister called `ic0.trap` with message: 'Panicked at 'protected task outlived its canister method (did you mean to use spawn_weak or spawn_migratory?)'

```

If I change `query` to `update` then all is good. Is there a way to call async functions from query functions? In this case, the async is just how the API works and under the hood, it’s just calling stable storage

---

<div class="post-metadata">

**Author:** ![AdamS](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/adams/32/5248_2.png) [@AdamS](https://forum.dfinity.org/u/AdamS)\
**Post date:** [January 2, 2026, 5:40pm UTC](https://forum.dfinity.org/t/await-in-a-query-function/62102/2 "2026-01-02T17:40:51Z")

</div>

If (and only if) there is no true asynchrony occurring, you can call [`futures::executor::block_on`](https://docs.rs/futures/latest/futures/executor/fn.block_on.html).

---

<div class="post-metadata">

**Author:** ![ranile](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ranile/32/34430_2.png) [@ranile](https://forum.dfinity.org/u/ranile)\
**Post date:** [January 5, 2026, 7:50am UTC](https://forum.dfinity.org/t/await-in-a-query-function/62102/3 "2026-01-05T07:50:10Z")

</div>

What are consequences of getting my assumption of no no true asynchrony happening wrong?

---

<div class="post-metadata">

**Author:** ![AdamS](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/adams/32/5248_2.png) [@AdamS](https://forum.dfinity.org/u/AdamS)\
**Post date:** [January 5, 2026, 12:55pm UTC](https://forum.dfinity.org/t/await-in-a-query-function/62102/4 "2026-01-05T12:55:02Z")

</div>

The only source of true asynchrony on the IC is inter-canister calls. If you aren’t making one internally, it isn’t truly async; and if you make one and try to block on it, you will get a trap saying that you exceeded the instruction limit (or that you failed to reply).
