Skip to content

[Test] SSE buffer boundary flush assertion too weak #170

@kianwoon

Description

@kianwoon

Description

The SSE buffer boundary flush test ("size threshold: flushes at \\n\\n boundary when bufferBytes exceeded") only checks expect(enqueue.mock.calls.length).toBeGreaterThanOrEqual(1) — it doesn't verify:

  1. The flushed chunk ends at a \n\n boundary
  2. The unflushed remainder (partial event) is retained for the next flush

The boundary scan (stream-buffer.ts:57-63) scans backwards for \n\n. This is a critical correctness path — flushing mid-event would corrupt the SSE stream.

Location

  • tests/stream-buffer.test.ts:36-48

Suggested Fix

Assert:

  • Flushed chunk ends with \n\n
  • Next flush contains the retained remainder

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions