Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/server/mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ func (m *sseManager) get(id string) (*sseSession, bool) {
m.mu.Lock()
defer m.mu.Unlock()
session, ok := m.sseSessions[id]
session.lastActive = time.Now()
if ok {
session.lastActive = time.Now()
}
return session, ok
}

Expand Down
16 changes: 16 additions & 0 deletions internal/server/mcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1168,3 +1168,19 @@ func TestStdioSession(t *testing.T) {
t.Fatalf("unexpected read: got %s, want %s", read, want)
}
}

func TestSseManagerGetNonExistentSession(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

m := newSseManager(ctx)

// Must not panic when session ID doesn't exist in the map.
session, ok := m.get("non-existent-id")
if ok {
t.Error("expected ok to be false for non-existent session")
}
if session != nil {
t.Error("expected nil session for non-existent ID")
}
}
Loading