mirror of https://github.com/sveltejs/svelte
fix: ignore false-positive errors of `$inspect` dependencies (#18106)
We had logic in place to ignore errors of `$inspect` effects that are about to destroy, but we didn't take into account that we can get these transient errors while checking for `is_dirty` in preparation for running the effect, too. Now effects are marked as dirty in case an error occurs while evaluating their dependencies, which guarantees we will see the error again but we can then handle it properly. Fixes #15741 --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/18163/head
parent
90a70cb012
commit
572444a696
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ignore false-positive errors of `$inspect` dependencies
|
||||
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
let {things} = $props();
|
||||
|
||||
$inspect(things);
|
||||
</script>
|
||||
|
||||
<ul>
|
||||
{#each things as thing}
|
||||
<li>thing {thing.id}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
@ -0,0 +1,21 @@
|
||||
import { normalise_inspect_logs } from '../../../helpers';
|
||||
import { test } from '../../test';
|
||||
import { flushSync } from 'svelte';
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
|
||||
async test({ assert, target, errors, logs }) {
|
||||
const button = target.querySelector('button');
|
||||
|
||||
flushSync(() => {
|
||||
button?.click();
|
||||
});
|
||||
|
||||
assert.htmlEqual(target.innerHTML, '<button>clear</button>');
|
||||
assert.equal(errors.length, 0);
|
||||
assert.deepEqual(normalise_inspect_logs(logs), [[{ id: 1 }, { id: 2 }]]);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,15 @@
|
||||
<script>
|
||||
import List from "./List.svelte"
|
||||
|
||||
let data = $state({things: [{id:1}, {id:2}]})
|
||||
|
||||
function reloadData() {
|
||||
data = null
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if data}
|
||||
<List things={data.things.map((t) => t)} />
|
||||
{/if}
|
||||
|
||||
<button onclick={() => reloadData()}>clear</button>
|
||||
Loading…
Reference in new issue