fix(runtime): prevent response stream truncation for large event-stre…#6696
fix(runtime): prevent response stream truncation for large event-stre…#6696ltanme wants to merge 1 commit intousebruno:mainfrom
Conversation
WalkthroughThese changes introduce a new SSE (Server-Sent Events) event stream parser module to handle streaming HTTP responses more robustly, integrate it into the network layer's data handling pipeline, and add a hexdump length limiter to prevent excessive memory consumption from large streaming chunks. Changes
Sequence Diagram(s)sequenceDiagram
participant HTTP as HTTP Stream
participant ESE as Event Stream<br/>Emitter
participant IPC as Electron IPC
participant App as Redux Store<br/>(collections)
rect rgb(230, 245, 255)
Note over HTTP,App: New SSE Streaming Flow
end
HTTP->>ESE: write(chunk)
ESE->>ESE: Accumulate in buffer<br/>(StringDecoder utf8)
ESE->>ESE: drain(): Scan for frame<br/>boundaries (CRLF/LF)
alt Frame detected
ESE->>ESE: Extract & parse SSE data
ESE->>IPC: onMessage(parsed data)
else Buffer exceeds threshold
ESE->>IPC: onMessage(raw buffer)<br/>(safety valve)
end
IPC->>App: main:http-stream-new-data<br/>{seq, timestamp, data}
App->>App: Limit hexdump to<br/>MAX_HEXDUMP_BYTES
HTTP->>ESE: end()
ESE->>ESE: Flush decoder & drain
ESE->>IPC: onMessage(final data)
IPC->>App: main:http-stream-end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (1)**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (CODING_STANDARDS.md)
Files:
🧠 Learnings (2)📚 Learning: 2025-12-05T20:31:33.005ZApplied to files:
📚 Learning: 2025-12-17T21:41:24.730ZApplied to files:
🧬 Code graph analysis (2)packages/bruno-electron/tests/network/event-stream-decoding.spec.js (1)
packages/bruno-electron/src/ipc/network/index.js (1)
🔇 Additional comments (10)
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 |
sid-bruno
left a comment
There was a problem hiding this comment.
General review
-
The
EventSourcespec while correctly referenced is not always followed and so it is valid to have ssetext/event-streamresponses where I might never getdata:, there's also json based streams in certain cases for example, https://sse.dev/testpage.html , so I can't really go forward -
The backpressure handling makes sense but you are in a node.js environment and can directly use one of the https://nodejs.org/api/stream.html solutions instead of the custom one here since that's already a lot more tested and will handle the backpressure better.

Description
This PR focuses on fixing streaming response truncation for
text/event-stream(SSE) responses, especially when large payloads or UTF‑8 multi-byte characters are split across network chunk boundaries.Context / Problem
When Bruno requests an SSE endpoint and the server streams a large amount of data:
What changed
StringDecoder) in the Electron main process, so no bytes are lost across chunk boundaries.\\n\\nand\\r\\n\\r\\n) and emit a complete SSE event to the renderer as a single message.data:lines are extracted and joined per the SSE parsing rules.Tests
Adds coverage for:
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit
Bug Fixes
New Features
✏️ Tip: You can customize this high-level summary in your review settings.