mirror of https://github.com/sveltejs/svelte
fix: simplify boundary error handling and handle hydration errors correctly (#18539)
remove the `catch` clause in `this.#run` - in two locations there's already a catch, and in the hydration-location we have to add special handling for hydration errors. --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>pull/18721/head
parent
bfc9b65b3d
commit
aadc97ce1b
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
const { environment } = $props();
|
||||
|
||||
if (environment === 'client') {
|
||||
throw new Error('oops');
|
||||
}
|
||||
</script>
|
||||
@ -0,0 +1,14 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['hydrate'],
|
||||
server_props: { environment: 'server' },
|
||||
props: { environment: 'client' },
|
||||
ssrHtml: 'loading inner loading nested',
|
||||
|
||||
async test({ assert, target }) {
|
||||
await tick();
|
||||
assert.htmlEqual(target.innerHTML, 'inner failed: oops outer failed: oops');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,24 @@
|
||||
<script>
|
||||
import Child from './Child.svelte';
|
||||
|
||||
const { environment } = $props();
|
||||
</script>
|
||||
|
||||
<svelte:boundary>
|
||||
<Child {environment} />
|
||||
{await new Promise(() => {})}
|
||||
|
||||
{#snippet pending()}loading inner{/snippet}
|
||||
{#snippet failed(error)}inner failed: {error.message}{/snippet}
|
||||
</svelte:boundary>
|
||||
|
||||
<svelte:boundary>
|
||||
<svelte:boundary>
|
||||
<Child {environment} />
|
||||
{await new Promise(() => {})}
|
||||
|
||||
{#snippet pending()}loading nested{/snippet}
|
||||
</svelte:boundary>
|
||||
|
||||
{#snippet failed(error)}outer failed: {error.message}{/snippet}
|
||||
</svelte:boundary>
|
||||
Loading…
Reference in new issue