Skip to content

Commit e15548d

Browse files
committed
fix: export wait function from internal client index
PR #17461 added the `wait` function to `reactivity/async.js` and modified the compiler to generate `$.wait()` calls, but forgot to export it from `index.js`. This causes a runtime error when using `await` inside `$derived()` with `experimental.async: true`: ``` TypeError: $.wait is not a function ``` Fixes #17529
1 parent 9108404 commit e15548d

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

.changeset/fix-wait-export.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: export `wait` function from internal client index

packages/svelte/src/internal/client/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export {
103103
run,
104104
save,
105105
track_reactivity_loss,
106-
run_after_blockers
106+
run_after_blockers,
107+
wait
107108
} from './reactivity/async.js';
108109
export { eager, flushSync as flush } from './reactivity/batch.js';
109110
export {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { tick } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
mode: ['client'],
6+
7+
props: {
8+
a_promise: Promise.resolve(10),
9+
b_promise: Promise.resolve(20)
10+
},
11+
12+
async test({ assert, target }) {
13+
await tick();
14+
await tick();
15+
16+
assert.htmlEqual(target.innerHTML, `<p>30</p>`);
17+
}
18+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script>
2+
let { a_promise, b_promise } = $props();
3+
</script>
4+
5+
<svelte:boundary>
6+
{@const a = await a_promise}
7+
{#if true}
8+
<svelte:boundary>
9+
{@const b = await b_promise}
10+
{#if true}
11+
{@const sum = a + b}
12+
<p>{sum}</p>
13+
{/if}
14+
</svelte:boundary>
15+
{/if}
16+
</svelte:boundary>

0 commit comments

Comments
 (0)