Skip to content

await order breaks bind: #17090

@techniq

Description

@techniq

Describe the bug

If you use await in <script> before a binded $state variable, an error is thrown:

Cannot read properties of undefined (reading 'f')

For example, this works:

<script>
	import Input from './Input.svelte';

	let value = $state(0);
	let data = await fetch('...');
</script>

<Input bind:value />

but this throws an error:

<script>
	import Input from './Input.svelte';

	let data = await fetch('...');
	let value = $state(0);
</script>

<Input bind:value />

Reproduction

REPL

Logs

Error: Cannot read properties of undefined (reading 'f')

	in <unknown>
	in __wrapper.svelte

    at get (playground:output:3903:22)
    at get value (playground:output:4737:13)
    at eval (playground:output:4622:87)
    at capture_store_binding (playground:output:4572:12)
    at prop (playground:output:4622:36)
    at Input (playground:output:4711:3)
    at App.add_svelte_meta.componentTag (playground:output:4735:10)
    at add_svelte_meta (playground:output:568:11)
    at App (playground:output:4734:3)
    at add_svelte_meta.componentTag (playground:output:4770:27)

System Info

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions