Svelte 5: #await block is evaluated after component is no longer rendered
Describe the bug
I have this code. As you can see on line 38 and 46, I have an await block that calls a promise to check if the current authenticated user is allowed to do some kind of action and display the button if so.
It basically render this.
Thing is when I change page, I get this error:
I must change line 47 to {#if policyResult && project?.id} to get rid of it. In my project it doesn't seems to matter if the promise has already resolved or not, it will still trigger the error. My bet would be that the page change must be re-triggering the pomise right before leaving the page likely because the project props changes to undefined. However! the key difference here is that it doesn't crash on line 29 but it does on line 48 which means it is evaluated sometimes later.
Reproduction
Honestly the project is too big to just share it and I wasn't sure what was the simplest aproach.
I made something where you can trigger the same error if you switch page before the promises are resolved:
I hope this is enough and it does replicate the "same" bug
System Info
5.0.0-next.245
Severity
annoyance
I successfully reproduced the bug with this REPL.
I think I found the origin of the problem, I will try to make a PR...
Closed by #13241