DEV Community

Lem Dulfo
Lem Dulfo

Posted on

IDE Warning When Calling Async Function with No Await

When should it be okay to not have an await for an async call?
Sometimes, I just want to call the async function, but not have to wait for its result. You might want your code to keep going, without needing the return value:

Image description

Thing is, the IDE will show a warning. It also signals to other devs in your team that "something may or may not be needed to be done for this warning". The worst that could happen is someone else tries to "fix" this by adding an await, and it slows down your app.

But if you're sure you're not waiting for the result and you want to signal to the IDE and your team that it's okay, here's what you can do.

Image description

Receive the result in _, which is generally accepted as a prefix for unused variables.

This way the IDE knows that you're aware that something is being returned, in this case it's a Promise, and that you're okay with not doing anything with the result.

This also keeps the visual tidy, while telling your teammates the intent. They won't be adding an unwanted await.

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay