mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-31 16:26:30 +00:00
fix(streaming): drop Anthropic ping keepalives before OpenAI conversion
Upstream Anthropic keepalive frames (event: ping) leaked into OpenAI Chat Completions SSE streams, crashing strict clients (Cursor, Hermes, OpenAI SDKs) on unexpected event types. Error events still forward. Fixes #5203
This commit is contained in:
@@ -418,6 +418,15 @@ func (s *GatewayService) handleCCStreamingFromAnthropic(
|
||||
}
|
||||
|
||||
processAnthropicEvent := func(event *apicompat.AnthropicStreamEvent) bool {
|
||||
if event == nil {
|
||||
return false
|
||||
}
|
||||
// Drop Anthropic keepalive pings before OpenAI conversion:
|
||||
// leaking `event: ping` frames crashes OpenAI-stream clients.
|
||||
// Error events must still forward — they carry upstream failures.
|
||||
if event.Type == "ping" {
|
||||
return false
|
||||
}
|
||||
if firstChunk {
|
||||
firstChunk = false
|
||||
ms := int(time.Since(startTime).Milliseconds())
|
||||
|
||||
Reference in New Issue
Block a user