question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

require-await Potential pitfall if used. Doc update maybe?

See original GitHub issue

Been using ESLint for a while, most rules are great.
But I would like to point out there is a major problem in enabling this rule.

The problem, take the code below.

async function test() { throw new Error("test"); }

There is no await, but what the async does here is guarantee a Promise. So the following code will return got.

test().catch(function (e) { console.log("got"); })

Take away the async and the above code is going to fail big time Now if you can guarantee you are always going to call test with await, you are ok again as await will check if it’s a Promise, but if you sent this to any other other Promise based consumers you have the above issue.

I’m mainly pointing this out as the Doc’s say nothing of this issue, and could potential cause hard to debug issues for people who are currently mixing Promise & async / await. So I wonder if a big warning of this potential pitfall should be put in the Doc’s.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Nov 7, 2018

I’ll take a stab at this.

1reaction
dhruvduttcommented, Aug 21, 2018

I would love to work on this. ✋ Can someone please describe the spec and point to some code?

Read more comments on GitHub >

github_iconTop Results From Across the Web

require-await - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Async/Await - Best Practices in Asynchronous Programming
Void-returning async methods have a specific purpose: to make asynchronous event handlers possible. It is possible to have an event handler that returns ......
Read more >
await - JavaScript - MDN Web Docs
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found