Repository navigation
fix(proxy): enforce SSE pending limit per event instead of per chunk - #9867
Merged
farion1231 merged 1 commit intoNov 23, 2026
Merged
Conversation
Owner
|
已合并,感谢您的贡献! 上次合并 #9846 时提到的那个小问题,这么快就修好了。现在只按当前这条事件到分隔符的长度判断是否超限,同一块里前面已经完整的事件也不会被连带丢掉;测试覆盖了分隔符被拆开、多字节字符被切开和 |
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.
Human Note / 本人说明
接 #9846 合并后维护者提到的边界问题(按整块算上限时,快满上限的正常事件和下一条同块到达会被误跳过)。改成只按当前事件到分隔符的长度判断,超限时只丢弃当前那条、保留前面已收尾的事件,并补回归测试。
Summary / 概述
current_event_start) inSseBufferwhenmax_pending_bytesis enabled (keeping the unboundedSseBuffer::new()fast path untouched).SseBuffer::push_bytesandSseBuffer::push_str, scan for the next SSE event delimiter usingSkipDelimiterState::from_pending(&self.text[self.current_event_start..], &self.utf8_remainder)and evaluate overflow against only the current event's bytes up to that delimiter instead of the entire incoming chunk.discard_current_event), shrink excess capacity, and clampscan_from, preserving any valid complete events already buffered earlier in the same chunk; advance directly past the delimiter when it falls within the current chunk.src-tauri/src/proxy/sse.rscovering near-limit events sharing a chunk with subsequent events (all 4 LF/CRLF delimiter forms, every split point, multi-byte UTF-8, andpush_str), preceding valid events preserved when a later event in the same chunk overflows, leading newlines/empty events across boundaries, andscan_fromclamping with split\n/\r/\nrecovery.Related Issue / 关联 Issue
Follow-up to #9846
Screenshots / 截图
N/A
Checklist / 检查清单
pnpm typecheckpasses / 通过 TypeScript 类型检查 (N/A — Rust-only change)pnpm format:checkpasses / 通过代码格式检查 (N/A — Rust-only change)cargo clippypasses (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)Verified locally:
cargo fmt --check --manifest-path src-tauri/Cargo.tomlcargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warningscargo test --manifest-path src-tauri/Cargo.toml --lib proxy::sse::tests(20 passed)cargo test --manifest-path src-tauri/Cargo.toml --lib proxy::response_processor::tests(19 passed)