Skip to content

Commit 5f92546

Browse files
committed
Fix for Notification Handler
1 parent 3628ca2 commit 5f92546

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/streamable_http.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,9 @@ func (s *StreamableHTTPServer) handleRequest(w http.ResponseWriter, r *http.Requ
484484
// Process the request
485485
response := s.server.HandleMessage(ctx, rawMessage)
486486

487-
// Restore the original notification handler
488-
if session != nil && originalNotificationHandler != nil {
487+
// Always restore the previous state (even if it was nil)
488+
// This prevents memory leaks from temporary handlers being left in place
489+
if session != nil {
489490
session.notifyMu.Lock()
490491
session.notificationHandler = originalNotificationHandler
491492
session.notifyMu.Unlock()

0 commit comments

Comments
 (0)