Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for top-level await with circular module import #4250

Open
theoludwig opened this issue Oct 8, 2024 · 2 comments · May be fixed by #4262
Open

Tests for top-level await with circular module import #4250

theoludwig opened this issue Oct 8, 2024 · 2 comments · May be fixed by #4262

Comments

@theoludwig
Copy link

theoludwig commented Oct 8, 2024

Repo: https://github.com/tc39/proposal-top-level-await/
Spec text: https://tc39.github.io/proposal-top-level-await/
ECMA-262 PR: tc39/ecma262#2408

In the Google Chrome v129 release, the JavaScript module import is broken with circular + top-level-await (discovered by @antfu).
Related:

To avoid other engines or implementers to also break accidentally this feature, or even for Google Chrome to avoid breaking it again, it would be great to add tests for this in Test262 (as suggested here: https://x.com/robpalmer2/status/1836846820418601384).

Demonstration

Online demo

When the entry file is foo.js, with the following content:

// bar.js
import { define } from './foo.js'

export default define('It works!')
// foo.js
export function define(foo) {
  return foo.toUpperCase()
}

const getter = () => import('./bar.js')

await 1

getter()
  .then(r => {
    // this will never be resolved
  })
  .catch(e => {
    // this either
  })

Note that if remove the await 1, it will work again.

@nicolo-ribaudo
Copy link
Member

Tests have been a used in #4116. Would you like to open a PR to move it out of the staging directory?

@theoludwig
Copy link
Author

Tests have been a used in #4116. Would you like to open a PR to move it out of the staging directory?

@nicolo-ribaudo Sure! 😄 PR opened: #4262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants