New issue
Advanced search Search tips

Issue 807528 link

Starred by 5 users

Issue metadata

Status: Duplicate
Merged: issue 829642
Owner:
Closed: Sep 25
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

Top-level `await import(...)` not working in console

Reported by rocca.jo...@gmail.com, Jan 31 2018

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36

Steps to reproduce the problem:
1. Open devtools console
2. Type `await fetch(location.href)`, confirm it's working fine
3. Now type `await import(location.href)` and you get an error: "Uncaught SyntaxError: await is only valid in async function"

What is the expected behavior?
Give a correct/descriptive error message (if for some reason this is not possible), or return the imported object.

What went wrong?
See above.

Did this work before? N/A 

Chrome version: 64.0.3282.119  Channel: stable
OS Version: 16.04
Flash Version:
 
Screenshot from 2018-01-31 13-43-36.png
26.5 KB View Download
To clarify, this obviously isn't because we're trying to import `location.href` as a module. Here's a better example to try:

`await import("https://cdn.rawgit.com/lodash/lodash/4.17.4-es/lodash.default.js")`

And we get the same error message
Labels: Needs-Triage-M64

Comment 3 by l...@chromium.org, Jan 31 2018

Owner: kozy@chromium.org
Status: Assigned (was: Unconfirmed)
Thanks for the great edge case!  kozy@ could you please take a look?
Just a note to say that this is still a problem, and that I also get the "await is only valid..." message when I have a comment in the code that I'm trying to execute:

```
await new Promise(r => setTimeout(r, 1000));
// this comment breaks it
```
Mergedinto: 829642
Status: Duplicate (was: Assigned)
It has two roots, most important is that we need a way to compile module using protocol.

Sign in to add a comment