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.

AWS Q Developer image

Your AI Code Assistant

Implement features, document your code, or refactor your projects.
Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (1)

Collapse
 
boly38 profile image
Brice

do someone know how to activate this lint warn on IntelliJ IDE ? I want it but it seems not possible from editor inspection options ..

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay