Function bindings broken in async component
Opened this issue · 4 comments
dylan1951 commented
Describe the bug
Since 5.43.0 function bindings are throwing various errors in async components.
Reproduction
<script>
await 1;
let value = $state('');
function getValue() { return value }
function setValue(v) { value = v }
</script>
<input bind:value={getValue, setValue} />Logs
Cannot read properties of undefined (reading 'f') in <unknown> in __wrapper.svelteSystem Info
Svelte playgroundSeverity
blocking an upgrade
dylan1951 commented
I haven't looked at the code, but I wonder if it's possible to add a step to run all existing tests but with await 1 appended at the top, this would have caught many of the issues reported recently.
henrykrinkle01 commented
In my experience, you declare everything else on top and move the await stuff to the very bottom of the script tag, so that they don't block the sync code. Or move it to the mark up with {@const foo = await...}, which seems to solve a lot of problems for me (currently have none)
await at the bottom
dummdidumm commented
We probably need to extend the "which of these things are needed to be awaited" logic to functions and analyze their body