From 62baa95ef843e086c8bac6bf2659b7252a8b07b2 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 8 Jun 2026 09:24:55 -0400 Subject: [PATCH] fix(server): log earlier so socket cleanup is always recorded Sets up the persistent log file before the client checks the socket, so any message about detecting or clearing a leftover socket is saved to disk instead of being lost. Co-Authored-By: Charm Crush --- internal/cmd/root.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/cmd/root.go b/internal/cmd/root.go index a8364ac4af3c32a21a36af35df9c40f4b278087c..b8e751b7ea47d40405974402a474037e69bf9ce4 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -416,6 +416,14 @@ func connectToServer(cmd *cobra.Command) (*client.Client, *proto.Workspace, func // version matches the client; on mismatch it shuts down the old server // and starts a fresh one. func ensureServer(cmd *cobra.Command, hostURL *url.URL) error { + // Initialize the persistent log here so stale-socket diagnostics + // emitted before connectToServer runs are captured in the per-host + // server log file. crushlog.Setup uses sync.Once internally, so the + // later call from connectToServer becomes a no-op. + debug, _ := cmd.Flags().GetBool("debug") + logFile := filepath.Join(config.GlobalCacheDir(), "server-"+safeHostName(hostURL), "crush.log") + crushlog.Setup(logFile, debug) + switch hostURL.Scheme { case "unix", "npipe": needsStart := false