# Not awaiting\* async\*

**URL:** <https://forum.dfinity.org/t/not-awaiting-async/18955>\
**Category:** Language Support\
**Tags:** Motoko\
**Created:** [March 16, 2023, 2:41am UTC](https://forum.dfinity.org/t/not-awaiting-async/18955 "2023-03-16T02:41:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [March 16, 2023, 2:41am UTC](https://forum.dfinity.org/t/not-awaiting-async/18955/1 "2023-03-16T02:41:06Z")

</div>

What happens if you don’t await\* and async\*?

With awaits, if you skip the await, the function still gets queued and called but your function doesn’t get to know the result.

I’m seeing some behavior with await\* that if I don’t await\* it then the code never actually gets run. Is that the case? I guess I can always not await any actual async termination points in my tree, but I was hoping to get the same behavior.

---

<div class="post-metadata">

**Author:** ![ggreif](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ggreif/32/301_2.png) [@ggreif](https://forum.dfinity.org/u/ggreif)\
**Post date:** [March 16, 2023, 8:59am UTC](https://forum.dfinity.org/t/not-awaiting-async/18955/2 "2023-03-16T08:59:34Z")

</div>

It’s not necessary to `await*` because computations are are simply inert objects, unless you are `await*`-ing them. So the only effect they cause is filling up memory with garbage if you don’t really use them. Nothing bad happens. If you know Haskell, this is like gadgets of type `IO String`, you can compose them to get bigger, sequential `IO x`, but they are just dormant.

Note that this is different from `async`, where the message (potentially to self) _will_ be sent. This also justifies the `*`: meaning zero or more sends. If you don’t `await*` it is definitively zero 🙂

---

<div class="post-metadata">

**Author:** ![ZhenyaUsenko](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/zhenyausenko/32/12200_2.png) [@ZhenyaUsenko](https://forum.dfinity.org/u/ZhenyaUsenko)\
**Post date:** [March 16, 2023, 9:04am UTC](https://forum.dfinity.org/t/not-awaiting-async/18955/3 "2023-03-16T09:04:31Z")

</div>

@skilesare This info is from **async** \* release notes

WARNING: Unlike `async`/`await`:

- an `async*` value has no effect unless `await*`-ed;
- each `await*` of the same `async*` value repeats its effects.

> **[Release 0.7.4 · dfinity/motoko](https://github.com/dfinity/motoko/releases/tag/0.7.4)**
>
> motoko (moc)
> 
> 
> Add new keywords async\* and await\* (note the \*) for efficient abstraction of asynchronous code (#3609).
> ::= ...
> async\* delayed, asynchronous computation...

---

<div class="post-metadata">

**Author:** ![Samer](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/samer/32/8943_2.png) [@Samer](https://forum.dfinity.org/u/Samer)\
**Post date:** [April 18, 2023, 3:18pm UTC](https://forum.dfinity.org/t/not-awaiting-async/18955/4 "2023-04-18T15:18:46Z")

</div>

@skilesare Do you have a nice example of async\* functions (preferably in a module) for documentation purposes in the [Motoko Book](https://web3.motoko-book.dev/advanced-concepts/async-programming/internal-async-await.html)?

My goals for that chapter of the book (async programming):  
I need to clearly state the difference between async and async\* and explain to a beginner when messages are sent, when execution is halted, when memory is rolled back (commit points), atomicity, errors, traps, try catch etc.

Any feedback and advice on this (arguably the most important) part of the book, would be much appreciated 🙂

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [April 18, 2023, 3:38pm UTC](https://forum.dfinity.org/t/not-awaiting-async/18955/5 "2023-04-18T15:38:56Z")

</div>

Not a lot of good ones yet, but I have been working on a Star.mo module that helps with keeping track of state inside of async\* functions: [GitHub - icdevs/star.mo: A library for dealing with async\* state.](https://github.com/icdevs/star.mo)
