Skip to content

Commit 6429019

Browse files
uppercavemanCHENBING1
and
CHENBING1
authored
Fix the issue where the 'Shutdown' method fails to properly exit. (#255)
* Fix the issue where the 'Shutdown' method fails to properly exit. * Fix the issue where the 'Shutdown' method fails to properly exit. --------- Co-authored-by: CHENBING1 <[email protected]>
1 parent b4686db commit 6429019

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

server/sse.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ func NewTestServer(server *MCPServer, opts ...SSEOption) *httptest.Server {
225225
// It sets up HTTP handlers for SSE and message endpoints.
226226
func (s *SSEServer) Start(addr string) error {
227227
s.mu.Lock()
228-
defer s.mu.Unlock()
229-
230228
if s.srv == nil {
231229
s.srv = &http.Server{
232230
Addr: addr,
@@ -239,8 +237,10 @@ func (s *SSEServer) Start(addr string) error {
239237
return fmt.Errorf("conflicting listen address: WithHTTPServer(%q) vs Start(%q)", s.srv.Addr, addr)
240238
}
241239
}
240+
srv := s.srv
241+
s.mu.Unlock()
242242

243-
return s.srv.ListenAndServe()
243+
return srv.ListenAndServe()
244244
}
245245

246246
// Shutdown gracefully stops the SSE server, closing all active sessions

0 commit comments

Comments
 (0)