Skip to content

fix: buffer SSE response reads - #2742

Draft
Anuja-jayasinghe wants to merge 1 commit into
ballerina-platform:masterfrom
Anuja-jayasinghe:fix/buffer-sse-event-reader
Draft

Anuja-jayasinghe wants to merge 1 commit into
ballerina-platform:masterfrom
Anuja-jayasinghe:fix/buffer-sse-event-reader

Conversation

@Anuja-jayasinghe

@Anuja-jayasinghe Anuja-jayasinghe commented Sep 30, 2026 •

Copy link
Copy Markdown

Purpose

This draft fixes the HTTP client's poor performance when reading large SSE events.

getSseEventStream currently requests one-byte chunks and performs one stream read for every byte while looking for the SSE event delimiter. This makes a 2 MB SSE event take several seconds even though the same data as a unary response is read in well under a second.

The change uses the normal buffered response stream and retains unread bytes locally. The parser still handles fragmented input and delimiters split across chunks, including one-byte chunks, without forcing every read to be one byte.

Examples

The repository's existing hostile-server s_huge case sends a 2,000,000-byte artifact in one SSE event. The same server also exposes the payload as u_huge in a unary response.

Path Measured time
Existing SSE reader 6.89–8.24 s
Buffered SSE reader 0.49–0.52 s
Unary response 0.41–0.49 s

The buffered reader returned the complete payload: 2,000,000 artifact bytes and 2,000,476 bytes including SSE framing. An integration test also covers a 64 KiB SSE event and verifies that the payload is not truncated.

Checklist

  • Linked to an issue — repository issues are disabled; no upstream issue was filed
  • Updated the changelog — pending maintainer direction for this draft
  • Added tests — large SSE event integration coverage
  • Updated the spec — not applicable; this is an implementation/performance fix
  • Checked native-image compatibility — not run locally
  • Checked the impact on OpenAPI generation — not applicable to the SSE reader

Signed-off-by: Anuja Jayasinghe <anujajayasinhe@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant