From 7884051cad41ec5b174ae668446f6f5fe171f359 Mon Sep 17 00:00:00 2001 From: dingo Date: Tue, 28 Apr 2026 17:19:26 -0400 Subject: [PATCH] fix(init): prevent stale sync timeout from firing after reset SceneTreeTimer callbacks captured _sync_timeout by reference rather than by identity, so a replaced timer's closure still passed the null-check and called _on_sync_failed even though progress was actively arriving. Fix by capturing the timer instance in the closure and bailing out if _sync_timeout no longer points to it. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Client/origin-client/scenes/init/init_screen.gd | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Client/origin-client/scenes/init/init_screen.gd b/Client/origin-client/scenes/init/init_screen.gd index 537a1aa..6b13f6f 100644 --- a/Client/origin-client/scenes/init/init_screen.gd +++ b/Client/origin-client/scenes/init/init_screen.gd @@ -255,10 +255,11 @@ func _stop_pulse() -> void: ## Start (or restart) the sync watchdog. If no progress arrives within ## SYNC_TIMEOUT_SEC, surface the retry button so the user isn't stranded. func _start_sync_timeout() -> void: - _sync_timeout = get_tree().create_timer(SYNC_TIMEOUT_SEC) - _sync_timeout.timeout.connect(func() -> void: - if not is_inside_tree() or _sync_timeout == null: - return + var t := get_tree().create_timer(SYNC_TIMEOUT_SEC) + _sync_timeout = t + t.timeout.connect(func() -> void: + if not is_inside_tree() or _sync_timeout != t: + return # stale timer — a newer one has already replaced us _sync_timeout = null push_warning("InitScreen: sync timed out — showing retry") _on_sync_failed("Timed out — tap Retry to try again."),