Skip to content

Parse failure: await isn't allowed in non-async function when using await with @const inside svelte:boundary #16856

@yuki0418

Description

@yuki0418

Describe the bug

Similar to #16811

<script>
  async function getOne() {
    return 1;
  }
</script>

<svelte:boundary>
	{@const one = await getOne()}
</svelte:boundary>

However, with pending snippet, it works.

<script>
  async function getOne() {
    return 1;
  }
</script>

<svelte:boundary>
	{@const one = await getOne()}
        {#snippet pending()}
		<p>loading...</p>
	{/snippet}
</svelte:boundary>

Reproduction

https://www.sveltelab.dev/bz2hl12ptw022ry

Logs

[vite] (ssr) Error when evaluating SSR module /src/routes/+page.svelte: Parse failure: await isn't allowed in non-async function
At file: /src/routes/+page.svelte:17:17
  File: /src/routes/+page.svelte:17:17
  15 |  
  16 |                          {
  17 |                                  const one = (await $.save(getOne()))();
     |                   ^
  18 |                          }
  19 |

System Info

N/A

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions