fix: reuse stream scanner buffer in channel handlers - #5225
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (8)
WalkthroughAdds a NewStreamScanner factory that centralizes bufio.Scanner buffer sizing and migrates channel stream handlers to use it; several handlers also add scanner error checks and remove now-unnecessary bufio imports. ChangesStream Scanner Consolidation
Possibly related PRs
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
25871fe to
b9a8b42
Compare
… id 等) 主要变更(QuantumNous/new-api → adc390c): - feat: 渠道被禁用后可配置是否清空渠道粘性 (QuantumNous#5306) - feat(web): profile 页显示 user id (QuantumNous#5317) - fix: 复用 channel handler 的 stream scanner buffer (QuantumNous#5225) - fix: 收窄 OpenAI o 系列模型适配范围 (QuantumNous#5293) - fix(relay): GLM Anthropic 兼容避免 chunked encoding (QuantumNous#5307) - fix: 新增 relay idle 连接超时配置 (QuantumNous#5309) - fix: 限制匿名请求体大小 (QuantumNous#5244) - fix(distributor): 修复 video generations task_id 模型解析 (QuantumNous#5133) - fix(dify): 远程图片字段赋值前初始化 file pointer (QuantumNous#5134) - fix(i18n): 优化 thinking adapter 文案 (QuantumNous#5242) 去合规一致性:上游未触及任何合规文件,合并完整保留本地去合规状态 (payment_setting.go / payment-settings-section.tsx / recharge-form-card.tsx / risk-acknowledgement-dialog.tsx 均未被改动)。 i18n:web/default 6 语言(en/zh/fr/ja/ru/vi)key 并集三路合并 + i18n:sync 规范化,4584 keys/语言,missing/extras/untranslated 全为 0。 验证:go build ./... ✅ + bun run typecheck ✅
…codes * origin/main: (45 commits) fix(openai): support streaming image relay and image edit for images API (QuantumNous#4608) perf(web): improve dialog sizing and footer layout feat(web): add shared dialog wrapper perf(web): simplify public page hero copy perf(model-pricing): move pricing tabs into page title feat(json-editor): add reusable JSON code editor perf(model-pricing): improve JSON pricing editor layout perf(model-pricing): reduce duplicate model name display fix: support six-decimal steps in model pricing editor fix: respect theme for multiselect combobox popover fix: reuse stream scanner buffer in channel handlers (QuantumNous#5225) fix: 收窄 OpenAI o 系列模型适配范围 (QuantumNous#5293) fix(i18n): clarify thinking adapter copy (QuantumNous#5242) fix: limit anonymous request body (QuantumNous#5244) fix(relay): fix Anthropic-compatible compatibility for GLM (avoid chunked encoding) (QuantumNous#5307) feat: 支持配置渠道被禁用后是否清空渠道粘性 (QuantumNous#5306) fix: add relay idle connection timeout config (QuantumNous#5309) feat(web): show user id on profile page perf(model-pricing): refine visual editor actions refactor(model-pricing): split visual pricing editor modules ... # Conflicts: # router/api-router.go # web/default/src/features/usage-logs/components/usage-logs-mobile-card.tsx
(cherry picked from commit 3280584)
Summary
helper.NewStreamScannerthat applies the existing stream scanner buffer limitFixes #5213
Tests
go test ./relay/helper -run TestNewStreamScanner_AllowsLargeStreamLine -count=1go test ./relay/channel/cohere ./relay/channel/zhipu ./relay/channel/cloudflare ./relay/channel/coze ./relay/channel/ollama ./relay/channel/tencentNote: full
go test ./relay/helperstill fails on existingTestStreamScannerHandler_StreamStatus_PreInitialized; the focused new scanner test passes.Summary by CodeRabbit
Refactor
Bug Fixes
Tests