Repository navigation
fix(proxy): 限制 SSE 转换器的单事件缓冲大小 - #9938
Merged
farion1231 merged 2 commits intoNov 27, 2026
Merged
Conversation
Apply the existing per-event size budget to stream converters and rewriters. Return a stream failure on overflow, bound JSON fallback documents, and cover the behavior with small in-memory inputs.
# Conflicts: # CHANGELOG.md
Owner
|
已合并,感谢您的贡献!转换层补上这道上限后,和日志层的防护对齐了。合并前我把 main 合进了分支,顺手去掉了 CHANGELOG 里的 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
本人说明
我看了一下,SseBuffer 默认是不限制大小的。Gemini 转换器直接用了这个 buffer,只要没收到分隔符,它就会一直往里塞数据,内存就无限涨。
概述
代理转换或改写上游 SSE 时,对每个事件应用 64 MiB 上限。单个事件超限后,按转换后的协议返回错误并结束当前流;正常事件仍可跨数据块接收,同一个数据块也可包含多个事件。兼容普通 JSON 响应的转换路径会额外检查整份文档的大小。历史记录层遇到超限事件时只跳过记录,仍原样转发字节。
关联 Issue
Fixes #9937
截图
不适用(仅后端改动)。
验证
检查清单
cargo fmt --checkcargo clippy --locked --offline --lib -- -D warnings