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.

Nested arrow async functions

See original GitHub issue
var a = async () => {
  return await (async () => {
    return await b();
  })();
};

It can’t parse this. It seems the syntax is OK.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
insidewhycommented, Jan 29, 2016

I get the same unknown expression of type... error even when not using nested async functions, sometimes just having an arrow function in an async function is enough to give that same error from babel. It also doesn’t give you a line number, just the file. Pretty serious bug.

0reactions
rjdestigtercommented, Apr 7, 2017

I’m having this issue at the moment using: node: 6.9.3 npm: 4.1.1 webpack: 2 + babel-preset-env + stage-0

presets: [
      ['env', {
        targets: {
          browsers: [
            '>1%',
            'last 2 versions',
            'not ie <= 11',
          ],
        },
        modules: false,
        useBuiltIns: false,
        debug: true,
      }],
      'react',
      'stage-0',
    ],

But only on a windows machine. On a linux machine no problems compiling.

Edit: I had everything installed using npm install however yarn was also available and after running yarn the issue was resolved. I’m assuming an older version of one of the dependencies was still present.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Array data gets lost in nested async arrow function loop
It just merrily continues through its loop and you log the value of courses and then sometime later, all the await operations inside...
Read more >
Arrow function expressions - JavaScript - MDN Web Docs
Syntax. Arrow functions can be async by prefixing the expression with the async keyword.
Read more >
41 Async functions - Exploring JS
An asynchronous function is any function that delivers its result asynchronously – for example, a callback-based function or a Promise-based function. An async ......
Read more >
Exploring Async/Await Functions in JavaScript - DigitalOcean
In this post we're quickly going over the ins and outs of async/await functions; introduced with ES2017 to help write synchronous-looking ...
Read more >
Deeply Understanding JavaScript Async and Await with ...
In the case of arrow function, async is put after the = sign and before the parentheses. Async functions can also be put...
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