-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
Description
- Version: 12.14.1
- Platform: macOS 10.14.x
- Subsystem:
What steps will reproduce the bug?
I run node with TLA support flag, I don't get the error if I do await on a top-level, but I do get the error if I do it in a for loop.
How often does it reproduce? Is there a required condition?
$ node --experimental-repl-await
Welcome to Node.js v12.8.1.
Type ".help" for more information.
> const timeout = delay => new Promise((res) => setTimeout(res, delay));
undefined
> timeout(1000).then(() => console.log('aaa'))
Promise { <pending> }
> aaa // this is displayed after 1 second, so it's fine
> await timeout(1000);
undefined // this is executed after 1 second, so it's also fine
> for (const i of [1, 2, 3]) {
... await timeout(1000);
Thrown:
await timeout(1000);
^^^^^
SyntaxError: await is only valid in async function
>
What is the expected behavior?
No error.
What do you see instead?
Error, see above.
Additional information
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.