From d69ddc1edc4c6df26cd6e6a20c040f2d6c6a29ef Mon Sep 17 00:00:00 2001 From: Eva H <63033505+hoyyeva@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:47:12 -0500 Subject: [PATCH] fix: window app crash on startup when update is pending (#14451) --- app/cmd/app/app.go | 11 +++++++++-- app/cmd/app/app_windows.go | 12 ++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/cmd/app/app.go b/app/cmd/app/app.go index 724c81619..e83fe47c9 100644 --- a/app/cmd/app/app.go +++ b/app/cmd/app/app.go @@ -296,8 +296,15 @@ func main() { // Check for pending updates on startup (show tray notification if update is ready) if updater.IsUpdatePending() { - slog.Debug("update pending on startup, showing tray notification") - UpdateAvailable("") + // On Windows, the tray is initialized in osRun(). Calling UpdateAvailable + // before that would dereference a nil tray callback. + // TODO: refactor so the update check runs after platform init on all platforms. + if runtime.GOOS == "windows" { + slog.Debug("update pending on startup, deferring tray notification until tray initialization") + } else { + slog.Debug("update pending on startup, showing tray notification") + UpdateAvailable("") + } } hasCompletedFirstRun, err := st.HasCompletedFirstRun() diff --git a/app/cmd/app/app_windows.go b/app/cmd/app/app_windows.go index 9caeb178a..3e2196dd7 100644 --- a/app/cmd/app/app_windows.go +++ b/app/cmd/app/app_windows.go @@ -154,6 +154,10 @@ func handleURLSchemeRequest(urlScheme string) { } func UpdateAvailable(ver string) error { + if app.t == nil { + slog.Debug("tray not yet initialized, skipping update notification") + return nil + } return app.t.UpdateAvailable(ver) } @@ -165,6 +169,14 @@ func osRun(shutdown func(), hasCompletedFirstRun, startHidden bool) { log.Fatalf("Failed to start: %s", err) } + // Check for pending updates now that the tray is initialized. + // The platform-independent check in app.go fires before osRun, + // when app.t is still nil, so we must re-check here. + if updater.IsUpdatePending() { + slog.Debug("update pending on startup, showing tray notification") + UpdateAvailable("") + } + signals := make(chan os.Signal, 1) signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)