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.

Add information to `no-return-await` docs about potential pitfalls.

See original GitHub issue

return await has subtly different semantics from just return in async functions. Example:

async function failing() {
  throw new Error('foo');
}

async function noAwait() {
  try {
    return failing();
  } catch (e) {
    return 'oops';
  }
}


async function withAwait() {
  try {
    return await failing();
  } catch (e) {
    return 'oops';
  }
}

noAwait().then(console.log, console.warn);
withAwait().then(console.log, console.warn);

This will call console.warn with the ‘foo’ error, which is thrown from noAwait. But it will log oops from the withAwait function. This is confusing behaviour, which might completely catch people off guard. So no, the await after return is not always superfluous, and recommending it’s removal might lead to subtle changes that was not expected.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, Jul 24, 2018

Sounds good to me!

0reactions
platinumazurecommented, Jul 24, 2018

@not-an-aardvark Any direction you want to provide in response to this comment? Or does the proposal there sound good? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rules - 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 >
JSHint Options Reference
Strict mode eliminates some JavaScript pitfalls that didn't cause errors by changing them to produce errors. It also fixes mistakes that made it...
Read more >
Social Media Dangers Documentary — Childhood 2.0
FIND MORE RESOURCES AT: https://bit.ly/32voKpY For the first time in history, mental illness and suicide have become one of the greatest ...
Read more >
In the Age of AI (full documentary) | FRONTLINE - YouTube
A documentary exploring how artificial intelligence is changing life as we know it — from jobs to privacy to a growing rivalry between...
Read more >
Pyour core schedule - bpm kids
Please contact us for more information. Variety of classes for all types of clients. Surf City, NJ 8008. Full service Pilates & fitness...
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