fix(mcp-session): send SSE endpoint event via local goroutine InjectData (#3567)

This commit is contained in:
Damos chen
2026-03-05 20:17:16 +08:00
committed by GitHub
parent aa502e7e62
commit 13b808c1e4

View File

@@ -140,10 +140,16 @@ func (s *SSEServer) HandleSSE(cb api.FilterCallbackHandler, stopChan chan struct
// Send the initial endpoint event
initialEvent := fmt.Sprintf("event: endpoint\ndata: %s\n\n", messageEndpoint)
err = s.redisClient.Publish(channel, initialEvent)
if err != nil {
api.LogErrorf("Failed to send initial event: %v", err)
}
go func() {
defer func() {
if r := recover(); r != nil {
api.LogErrorf("Failed to send initial event: %v", r)
}
}()
defer cb.EncoderFilterCallbacks().RecoverPanic()
api.LogDebugf("SSE Send message: %s", initialEvent)
cb.EncoderFilterCallbacks().InjectData([]byte(initialEvent))
}()
// Start health check handler
go func() {