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 <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -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."),
|
||||
|
||||
Reference in New Issue
Block a user