Commit 890399b
Fix: Don't wrap await inside @const async functions with save
The issue was that `is_reactive_expression` was returning true for all awaits inside @const tags because `in_derived` was set to true. This caused awaits inside async functions assigned to @const to be incorrectly pickled with $.save(), breaking reactivity.
The fix checks if there's a function in the path between the await and any reactive context. If there's a reactive rune call ($derived, $effect, etc.) between the function and the await, it's still considered reactive. Otherwise, it's not.
This preserves the correct behavior for $derived with await inside async functions while fixing the @const async function case.
Co-authored-by: dummdidumm <[email protected]>1 parent c996279 commit 890399b
File tree
1 file changed
+22
-5
lines changed- packages/svelte/src/compiler/phases/2-analyze/visitors
1 file changed
+22
-5
lines changedLines changed: 22 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | 56 | | |
61 | 57 | | |
62 | 58 | | |
| |||
67 | 63 | | |
68 | 64 | | |
69 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
70 | 87 | | |
71 | 88 | | |
72 | 89 | | |
| |||
76 | 93 | | |
77 | 94 | | |
78 | 95 | | |
79 | | - | |
| 96 | + | |
80 | 97 | | |
81 | 98 | | |
82 | 99 | | |
| |||
0 commit comments