Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { flushSync } from 'svelte';
import { test } from '../../test';

export default test({
test({ assert, target, logs }) {
let btn = target.querySelector('button');

btn?.click();
btn?.click();
flushSync();

assert.deepEqual(logs, ['error caught 1', 'error caught 2']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is behaving correctly, the assertion is wrong (and nonsensical! where did error caught 2 come from?). test is outside the error caught 1 boundary, and so the only thing that should get logged is error caught root:

Suggested change
assert.deepEqual(logs, ['error caught 1', 'error caught 2']);
assert.deepEqual(logs, ['error caught root']);

The mystery here is why error-boundary-19 appears to behave differently, despite #16091

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured out at least part of the mystery: when update_reaction(derived) inside execute_derived, the finally block, which undoes set_active_effect(get_derived_parent_effect(derived)), happens before the error is handled

}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script lang="ts">
import Test from './test.svelte';
</script>

<svelte:boundary onerror={(e) => {console.log('error caught root')}}>
<Test />
</svelte:boundary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script>
let count = $state(0);

let test = $derived.by(() => {
if (count > 1) {
throw new Error('test');
}
});
</script>

<svelte:boundary onerror={(e) => {console.log('error caught 1')}}>
<div>Count: {count}</div>
<button onclick={() => count++}>Increment</button>
{count} / {test}
</svelte:boundary>
Loading