Warn when `await` keyword might be missing
See original GitHub issuePicking up https://github.com/babel/babel-eslint/issues/593 and https://github.com/eslint/eslint/issues/9787
Some of the meanest kinds of bugs we are running into are race conditions happening at runtime because of accidentally missing await
statements.
Others run in this, too. Quoting @aymericbouzy:
My real pain point is the following: I have a large codebase, and when my code runs, I encounter bugs that are difficult to reproduce, unpredictable results … simply because I forgot to await a promise. Here is a simple example where not awaiting a promise leads to bad results:
(https://github.com/eslint/eslint/issues/9787#issuecomment-367264702)
Now, I think we already know that ESLint cannot reliably detect these errors. I think that @ljharb is right with this statement:
This is what a type system and/or tests are for; this just isn’t a lintable problem.
But in practice I often times find myself in a situation where the type system doesn’t catch the problem either or where the effort to make it detect the problem would simply be quite large.
Pragmatically, a simple warning when an await
keyword might be missing would do wonders.
Then I can still decide if that’s the case or not.
What do you think?
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (7 by maintainers)
To clarify, it sounds like you’re suggesting a rule that would warn on all function calls found in an
async
function body that are notawait
ed. Is that right?If so, I don’t think this should be a rule in core. I also don’t think this is a particularly helpful rule in general, because I’ve never encountered a codebase where all function calls are asynchronous. This means that there would be a lot of false positives and negatives, and would most likely produce a lot of useless warnings. In my experience, this leads to people ignoring the warning altogether.
I’m a bit confused as to why a type system isn’t helping you here. In my experience with TypeScript, at least, these kinds of errors have been caught.
Without a type system, that’s just not possible in the most common case, which is when the other async function is in another file.