From 22ad70880283a818a926a272e95f6bf8a7614c38 Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Sun, 30 Aug 2026 10:25:39 +0200 Subject: [PATCH] Log session_id on engine session close, not just the user-grouping label "Session closed" only logged session.logger's bound "session" field, which is the user's short ID (not this session's own) whenever authenticated - deliberately shared across every reconnect for that user so log lines group together by grep. Without an explicit session_id (unlike "Session established", which already logs one), two rapid reconnects for the same user produced two indistinguishable "Session closed" lines, which read as a session-eviction/map-corruption bug in a live triage when the actual cause was simply frequent reconnects from a duplicate-client bug elsewhere. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_014CUkUYCxTRRRrvVWSGS5dj --- internal/engine/session.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/engine/session.go b/internal/engine/session.go index 26a9c5ed..c1b98067 100644 --- a/internal/engine/session.go +++ b/internal/engine/session.go @@ -618,7 +618,14 @@ func (m *Manager) unregisterSession(session *Session) { _ = m.sessionStore.Delete(context.Background(), session.ID) } - session.logger.Info("Session closed") + // "session" (session.logger's bound field) is the user's short ID, not + // this session's own - deliberately shared across every reconnect for + // that user so log lines from the same user grep together. Without an + // explicit session_id here (unlike "Session established", which already + // logs one), two rapid reconnects for one user produce two "Session + // closed" lines that are indistinguishable from each other, which read + // as a session-eviction bug when reconnects were simply frequent. + session.logger.Info("Session closed", zap.String("session_id", session.ID)) } // validateToken authenticates tokenString and returns its identity.