From 391a4878e68b73374ff6ffc528c60a57d0fbd807 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:36:16 +0100 Subject: [PATCH] perf: replace JSON.parse(JSON.stringify()) with structuredClone in layout (#22104) Replace JSON roundtrip with native structuredClone for tool execution result cloning. Also remove unnecessary JSON roundtrip on a static error object literal that is already a fresh value. --- src/routes/+layout.svelte | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 398134d0a4..42768ca99d 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -343,17 +343,11 @@ } if (cb) { - cb(JSON.parse(JSON.stringify(res))); + cb(structuredClone(res)); } } else { if (cb) { - cb( - JSON.parse( - JSON.stringify({ - error: 'Tool Server Not Found' - }) - ) - ); + cb({ error: 'Tool Server Not Found' }); } } };