bug: Streams that are not SSE (Bedrock, Ollama NDJSON) reach the client only when they end

未关闭
#1,880 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go

调研方向

Start in core/listener/forwardproxy/server.go around lines 972 and 1015, then read the existing fix for #1879. Reproduce with a Go test that sends five flushed event-stream lines at 400 ms intervals, with and without a body-reading plugin. Done means supported non-SSE streams reach the client incrementally and are not buffered until completion.

由索引模型根据 Issue 内容生成。

描述

bug laptop

Problem

The proxy streams a response only when its type is text/event-stream. It buffers all other streaming responses until they are complete. These streams arrive at the client only at the end:

  • Bedrock invoke-with-response-stream (application/vnd.amazon.eventstream)
  • Ollama /api/chat (application/x-ndjson)
  • Gemini streamGenerateContent without alt=sse

These streams also get a 502 when they are larger than 10 MB (see #1879).

Reproduction (main at 676557d35)

A Go test that builds forwardproxy.NewServer with one ReadsBody plugin. The upstream sends Content-Type: application/vnd.amazon.eventstream and writes one line every 400 ms, five times, with a flush after each line.

Result: the client gets the first line after 2.007 s, which is when the upstream ends the stream. Without the proxy, the first line arrives at about 0 s.

Cause

core/listener/forwardproxy/server.go:972: httpx.IsEventStream is the only test for a stream. All other responses go to the buffered branch at server.go:1015 when any plugin reads bodies. inference-parser always reads bodies.

Fix

Use the same fix as #1879: buffer only parsed traffic. Also send ContentLength == -1 responses through flushWriter when no plugin must read them.

Impact if not fixed

Claude Code on Bedrock through Cortex shows no streamed output. Local Ollama and Gemini clients that use these formats have the same problem.

主要语言
Go
星标
26
派生
46
平均合并
9 小时 55 分钟
30 天内合并 PR
257

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rossoctl/cortex 的其他 Issue

查看 rossoctl/cortex 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。