fix(streaming): bound translated SSE inspection (#1112) - #1133
Conversation
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe translated request-log tracker and heartbeat relay now use ChangesSSE inspection integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant UpstreamStream
participant SSEInspector
participant RequestLogTracking
participant HeartbeatRelay
participant Observers
UpstreamStream->>RequestLogTracking: SSE chunks
RequestLogTracking->>SSEInspector: feed chunks
SSEInspector->>Observers: bounded parsed payload
RequestLogTracking->>SSEInspector: finish and dispose
UpstreamStream->>HeartbeatRelay: SSE chunks
HeartbeatRelay->>SSEInspector: feed chunks
SSEInspector->>Observers: heartbeat and terminal observations
HeartbeatRelay->>SSEInspector: finish and dispose
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Summary
Bounds the translated-path SSE inspection so a delimiterless upstream stream can no longer pin memory or triple parse cost.
trackSseForRequestLog(src/server/relay.ts:353) accumulated decoded bytes into an unbounded buffer insideinspectChunkand re-parsed every complete payload through three separate string helpers;relaySseWithHeartbeatrepeated the same unbounded append. 64 MiB of delimiterless upstream bytes therefore stayed resident and were scanned three times.Both scanners now use the existing byte-bounded
createSseInspector: an over-cap frame is discarded from inspection only, the parser resynchronizes at the next SSE delimiter, and the payload is parsed once and shared across the request-log, first-output, and terminal observers. Bytes relayed downstream are unchanged — the regression test asserts byte-for-byte preservation.Closes #1112.
Attribution
This is @Ingwannu's work from #1114, cherry-picked with their authorship intact (
git logshows them as the commit author, not me). #1114 is left open for them; I have not closed it. Thank you for the clean, correctly-layered fix — reusing the existing inspector rather than writing a third scanner is exactly right.This is stack 1 of a stacked campaign landing the current bug backlog with contributor attribution preserved. Planning unit:
devlog/_plan/260806_stacked_bug_campaign/.Verification
bun test tests/sse-inspector-bounds.test.ts— 23 pass, 0 failbun run typecheck— exit 0bun run privacy:scan— passedbun run testvia the repository prepush gate — passedChecklist
Summary by CodeRabbit
Bug Fixes
Documentation
Tests