mirror of https://github.com/sveltejs/svelte
fix: set server context after async transformError (#17799)
This will get the tests in https://github.com/sveltejs/kit/pull/15308 green, right now they fail because page state cannot be found because context not availablepull/17786/head
parent
3a289797bd
commit
673a1ab964
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: set server context after async transformError
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
import { tick } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
mode: ['hydrate', 'async-server', 'client'],
|
||||||
|
ssrHtml: '<p>caught: error (hello)</p>',
|
||||||
|
transformError: () => {
|
||||||
|
return Promise.resolve('error');
|
||||||
|
},
|
||||||
|
|
||||||
|
async test({ assert, target }) {
|
||||||
|
await tick();
|
||||||
|
assert.htmlEqual(target.innerHTML, '<p>caught: error (hello)</p>');
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
<script>
|
||||||
|
import { get } from "./main.svelte";
|
||||||
|
|
||||||
|
let { error } = $props();
|
||||||
|
const context = get()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if error}
|
||||||
|
<p>caught: {await error} ({context})</p>
|
||||||
|
{:else}
|
||||||
|
{(() => {
|
||||||
|
throw 'catch me';
|
||||||
|
})()}
|
||||||
|
{/if}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
<script module>
|
||||||
|
import { createContext } from "svelte";
|
||||||
|
import Child from "./child.svelte";
|
||||||
|
|
||||||
|
const [ get, set ] = createContext();
|
||||||
|
export {get};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
set('hello');
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:boundary>
|
||||||
|
{#snippet failed(error)}
|
||||||
|
<Child {error} />
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
<Child />
|
||||||
|
</svelte:boundary>
|
||||||
Loading…
Reference in new issue