Skip to content

Await doesn't work inside of Fragments #13334

@jlwalkerlg

Description

@jlwalkerlg

Astro Info

Astro                    v5.3.0
Node                     v22.13.0
System                   Windows (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Using await inside of a <Fragment> element throws the following error message:

[ERROR] "await" can only be used inside an "async" function

For example, this markup in the <head> produces the above console error:

<Fragment>
  <link
    rel="preload"
    href={(await import('../fonts/brown-sugar.woff2')).default}
    as="font"
    crossorigin
  />
</Fragment>

Whereas this markup doesn't:

<link
  rel="preload"
  href={(await import('../fonts/brown-sugar.woff2')).default}
  as="font"
  crossorigin
/>

This is perhaps related to this issue, but that issue seems specific to using set:html.

What's the expected result?

await should work inside of <Fragment> elements.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-qagmg7gy?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions