Empty SSE Events Leak Through Opencode Stream Processor #1869

Closed
opened 2026-02-16 17:33:01 -05:00 by yindo · 2 comments
Owner

Originally created by @shantur on GitHub (Sep 28, 2025).

Originally assigned to: @rekram1-node on GitHub.

  • Summary: The shared SSE client in opencode/packages/sdk/js/src/gen/core/serverSentEvents.gen.ts emits an event for every data: stanza, even if the
    payload is empty/whitespace. Downstream code receives meaningless events, forcing consumers (e.g., the Gemini plugin) to filter them manually.
  • Impact: Plugins/tools that listen to streamed deltas must implement custom guards to avoid processing blank events. This leads to duplicated logic,
    brittle handling of real "" payloads, and wasted work for every SSE consumer.

This is visible when working with Gemini CLI OAauth

Propsed fix

opencode/packages/sdk/js/src/gen/core/serverSentEvents.gen.ts (+3 -0)
    155                    const rawData = dataLines.join("\n")
    156   +                if (!rawData.trim()) {
    157   +                  continue
    158   +                }
    159                    try {
Originally created by @shantur on GitHub (Sep 28, 2025). Originally assigned to: @rekram1-node on GitHub. - Summary: The shared SSE client in opencode/packages/sdk/js/src/gen/core/serverSentEvents.gen.ts emits an event for every data: stanza, even if the payload is empty/whitespace. Downstream code receives meaningless events, forcing consumers (e.g., the Gemini plugin) to filter them manually. - Impact: Plugins/tools that listen to streamed deltas must implement custom guards to avoid processing blank events. This leads to duplicated logic, brittle handling of real "" payloads, and wasted work for every SSE consumer. This is visible when working with Gemini CLI OAauth Propsed fix ``` opencode/packages/sdk/js/src/gen/core/serverSentEvents.gen.ts (+3 -0) 155 const rawData = dataLines.join("\n") 156 + if (!rawData.trim()) { 157 + continue 158 + } 159 try { ```
yindo closed this issue 2026-02-16 17:33:01 -05:00
Author
Owner

@rekram1-node commented on GitHub (Sep 28, 2025):

@shantur do u know which event types are being sent as blank strings?

@rekram1-node commented on GitHub (Sep 28, 2025): @shantur do u know which event types are being sent as blank strings?
Author
Owner

@shantur commented on GitHub (Sep 28, 2025):

@rekram1-node : heartbeat was one for sure

@shantur commented on GitHub (Sep 28, 2025): @rekram1-node : heartbeat was one for sure
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1869