From a878dee0d92fd8a1f30585953e5dfb81b604cebf Mon Sep 17 00:00:00 2001 From: "claude (blind_chess)" Date: Tue, 28 Apr 2026 11:32:29 -0400 Subject: [PATCH] fix(client): wrap connect/disconnect in untrack() to break effect loop Svelte 5 $effect tracks every $state read inside its body. The lifecycle effect that calls game.connect(gameId) implicitly read state.ws (inside connect()) and then wrote to it, producing an effect_update_depth_exceeded loop. Symptom in production: the browser opened ~12 WS connections/sec, none completed the upgrade handshake, and the lobby flow appeared stuck on 'waiting for opponent' (the opponent's WS never stabilized long enough for the server to send 'joined'). untrack() opts the call out of dep tracking. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/client/src/lib/Game.svelte | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/client/src/lib/Game.svelte b/packages/client/src/lib/Game.svelte index ef982a3..265146d 100644 --- a/packages/client/src/lib/Game.svelte +++ b/packages/client/src/lib/Game.svelte @@ -1,4 +1,5 @@