Does an async function always need to be called with await? Does an async function always need to be called with await? node.js node.js

Does an async function always need to be called with await?


It is not necessary if your logic doesn't require the result of the async call. Although not needed in your case, the documentation lists two benefits to having that warning enabled:

While this is generally not necessary, it gives two main benefits. The first one is that you won't forget to add 'await' when surrounding your code with try-catch. The second one is that having explicit 'await' helps V8 runtime to provide async stack traces


When you set async to a method, the method expects to use await inside its scope. Because the functionality of async keyword is like if you were telling to the method that inside its scope there's another process which must be completed before can proceed to the method process.

In other words, if you don't want to await to some other process to finish, then you should avoid async keyword in your method.

Here, makes sense the await keyword:

await msg.save();

Because it awaits till it's saved before log that is Done. But in the methods you want all run without waiting for other processes to end. Just don't use asyn keyword. If you don't want to await here:

await this.rs.reply(username, message, this);

Don't use async here:

async getReply(username, message)

If you need to await something in getReply then you should add async keyword, otherwise, is not necessary the keyword.


Whenever you want to await some operation you have to associate await with that but before associate await with that you need to make parent function async.