diff --git a/.changeset/rich-waves-mix.md b/.changeset/rich-waves-mix.md new file mode 100644 index 0000000000..5b640517b9 --- /dev/null +++ b/.changeset/rich-waves-mix.md @@ -0,0 +1,5 @@ +--- +"svelte": patch +--- + +fix: try-catch deep read during `$inspect` diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index 9bc049ecbb..60183520a8 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -1965,7 +1965,11 @@ function deep_read(value, visited = new Set()) { if (typeof value === 'object' && value !== null && !visited.has(value)) { visited.add(value); for (let key in value) { - deep_read(value[key], visited); + try { + deep_read(value[key], visited); + } catch (e) { + // continue + } } const proto = Object.getPrototypeOf(value); if ( @@ -1979,7 +1983,11 @@ function deep_read(value, visited = new Set()) { for (let key in descriptors) { const get = descriptors[key].get; if (get) { - get.call(value); + try { + get.call(value); + } catch (e) { + // continue + } } } }