Skip to content

Preserve Linux streaming lines across HTTP chunks - #200

Merged
jamesrochabrun merged 1 commit into
mainfrom
fix/linux-stream-chunk-boundaries
Sep 9, 2026
Merged

jamesrochabrun merged 1 commit into
mainfrom
fix/linux-stream-chunk-boundaries

Conversation

@jamesrochabrun

Copy link
Copy Markdown
Owner

Linux streaming treated arbitrary HTTP body chunks as complete lines. A JSON line or UTF-8 character split between chunks could therefore reach the consumer incomplete, and chunk boundaries could add spurious empty lines.

Buffer bytes until a real LF, CRLF or CR delimiter, retain only the pending EOF tail, read the ByteBuffer readable region, and cancel the body producer when its consumer terminates. Malformed payloads and connection errors remain errors for the caller to classify.

Validation:

  • Full SDK suites: 101 tests on macOS and 99 on Linux arm64, zero failures.
  • Seven new regressions cover every byte split of a JSON/UTF-8 event, one-byte/empty chunks, line boundaries, partial EOF, malformed payload forwarding, connection failure and cancellation. The original implementation fails 77 assertions in the four boundary regressions.
  • Nine downstream CLI integration cases pass in disposable Linux containers with networking disabled and a scripted loopback provider. The released adapter fails three valid split-response cases; the patched adapter completes all three with exact text. Malformed input still fails, cancellation closes the connection, and each case makes one request with valid JSON output.
  • Repository formatting and whitespace checks pass. No external model calls were used.

Retain incomplete lines and UTF-8 characters until a real delimiter so network chunk boundaries cannot corrupt decoder input. Cancel the body producer when its consumer terminates.
@jamesrochabrun
jamesrochabrun marked this pull request as ready for review September 9, 2026 21:58
@jamesrochabrun
jamesrochabrun merged commit c757e0b into main Sep 9, 2026
4 checks passed
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