mirror of https://github.com/sveltejs/svelte
fix: wrap `Promise.all` in `save` during SSR (#18178)
Closes #18168 Not sure if there's a deeper issue in play because the error it's only really there if you also add a title to the component. I think the issue is that with multiple arguments the top level `Promise.all` is not wrapped in `save` and that probably causes a race condition with `title` that sets the context back to `null` in a `finally`. One issue is that now the generated code looks like this ```js const [$$0, $$1] = (await $.save(Promise.all([ (async () => (await $.save(user()))().name)(), (async () => (await $.save(user()))().image)() ])))(); ``` which seems a bit redundant, but I'm not sure if we can get rid of the inner `save` since they are indeed awaiting something.pull/18183/head
parent
dc5bd887b5
commit
89b6a939fe
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: wrap `Promise.all` in `save` during SSR
|
||||
@ -0,0 +1,8 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['async'],
|
||||
compileOptions: {
|
||||
dev: true
|
||||
}
|
||||
});
|
||||
@ -0,0 +1 @@
|
||||
<!--[--><img alt="test" src=""/><!--]-->
|
||||
@ -0,0 +1 @@
|
||||
<!--1410iyz--><!----><title>Async multiple attributes</title>
|
||||
@ -0,0 +1,15 @@
|
||||
<script>
|
||||
const user = $derived(Promise.resolve({
|
||||
name: 'test',
|
||||
image: '',
|
||||
}))
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Async multiple attributes</title>
|
||||
</svelte:head>
|
||||
|
||||
<img
|
||||
alt={(await user).name}
|
||||
src={(await user).image}
|
||||
/>
|
||||
Loading…
Reference in new issue