Skip to content

Commit 87f7e97

Browse files
authored
fix: wrap async children in $$renderer.async (#16862)
1 parent 8895bd4 commit 87f7e97

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

.changeset/rude-terms-confess.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: wrap async `children` in `$$renderer.async`

packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/component.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,12 @@ export function build_inline_component(node, expression, context) {
242242
params.push(pattern);
243243
}
244244

245-
const slot_fn = b.arrow(params, b.block(block.body));
245+
const slot_fn = b.arrow(
246+
params,
247+
node.fragment.metadata.has_await
248+
? b.block([create_async_block(b.block(block.body))])
249+
: b.block(block.body)
250+
);
246251

247252
if (slot_name === 'default' && !has_children_prop) {
248253
if (
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!--[--><!--[--><!---->1<!--]--><!----><!--]-->
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<script>
2+
const { children } = $props();
3+
</script>
4+
{@render children()}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
import Component from "./component.svelte";
3+
</script>
4+
<Component>
5+
{@const one = await 1}
6+
{one}
7+
</Component>

0 commit comments

Comments
 (0)