Encode empty-data SSE events as dispatchable events - #6975
Conversation
🦋 Changeset detectedLatest commit: 8ee0d59 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
This PR lands the regression test, but the implementation fix described in the title and PR body is still missing. The test correctly fails until the encoder change is added.
Reviewed changes
- Added a single regression round-trip test in
packages/effect/test/unstable/encoding/Sse.test.tsthat verifies anEventwithdata: ""round-trips throughSse.encoderandSse.makeParser.
⚠️ Implementation fix is required before merge
The diff currently only adds the failing test. Sse.encoder at packages/effect/src/unstable/encoding/Sse.ts:665 still skips the data: field when event.data === "", so the event dispatches nothing. To satisfy the expected behavior stated in the PR body, remove the if (event.data !== "") guard so an empty data value still emits data: and makeParser will dispatch it.
⚠️ Changeset needed
Because the eventual fix changes runtime encoding behavior, add a changeset under .changeset/ before merging.
@v0 or keep the SHA fresh with Dependabot | Fix it ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Removed the
if (event.data !== "")guard inpackages/effect/src/unstable/encoding/Sse.tsso an emptydatavalue still emits adata:line andmakeParserdispatches the event. - Added a changeset under
.changeset/empty-geckos-dispatch.mddescribing the patch-level runtime behavior change. - The regression test added in the previous commit now passes.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
232cca3 to
d9cc206
Compare
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The new head rebases the previously approved fix onto latest main and splits it into two commits without changing the net diff:
- Removed the
if (event.data !== "")guard inpackages/effect/src/unstable/encoding/Sse.tsso an emptydatavalue still emits adata:line andmakeParserdispatches the event. - Added a regression test in
packages/effect/test/unstable/encoding/Sse.test.tsthat verifies anEventwithdata: ""round-trips throughSse.encoderandSse.makeParser. - Added a changeset under
.changeset/empty-geckos-dispatch.mddescribing the patch-level runtime behavior change.
Validation run: pnpm --filter effect test --run test/unstable/encoding/Sse.test.ts, pnpm lint-fix, and pnpm check all pass.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
d9cc206 to
8ee0d59
Compare

Summary
Encoding and reparsing an accepted event whose data is the empty string produces no event.
Important
This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.
SSE encoder drops empty-data events
Module:
encoding/SseAudit ID:
unstable-ai-cli-sse-empty-data-event-droppedSeverity / confidence: medium / high
What happens
Encoding and reparsing an accepted event whose data is the empty string produces no event.
Why it happens
The encoder omits data: for empty data and writes only a blank terminator, which the parser ignores while its data buffer is empty.
Expected behavior
Every accepted Event, including data equal to the empty string, renders as an SSE event that can be dispatched.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/effect/src/unstable/encoding/Sse.ts:654-669View problematic code at
packages/effect/src/unstable/encoding/Sse.ts:654-669View exact lines on GitHub
Reproduction
pnpm test --run packages/effect/test/unstable/encoding/Sse.test.tsObserved failure: FAIL: the round-trip produced no event.
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
pnpm test --run packages/effect/test/unstable/encoding/Sse.test.tsAudit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715funstable-ai-cli-sse-empty-data-event-droppedCloses EFF-416