Skip to content

Fix LineBuffer payload byte accounting - #98

Open
Sagar07-star wants to merge 1 commit into
Netflix:mainfrom
Sagar07-star:fix/line-buffer-byte-size
Open

Sagar07-star wants to merge 1 commit into
Netflix:mainfrom
Sagar07-star:fix/line-buffer-byte-size

Conversation

@Sagar07-star

@Sagar07-star Sagar07-star commented Oct 10, 2026 •

Copy link
Copy Markdown

Summary
Count the UTF-8 payload bytes, including newline separators, when deciding whether LineBuffer should flush.
Problem
LineBuffer currently counts only characters in each input line, while SocketWriter sends the newline-joined buffer encoded as UTF-8. For example, two three-character lines produce seven payload bytes but count as six, so a seven-byte threshold does not trigger a flush.
Changes

  • Include one separator byte for each line after the first.
  • Count encoded UTF-8 bytes instead of characters.
  • Add regression coverage for separator-triggered flushing, multibyte text, empty lines, and size reset after flushing.
    The threshold still triggers after appending a whole line; this does not introduce a strict datagram size cap.
    Validation
  • All four LineBuffer tests fail before the fix and pass afterward (including the corrected existing size expectation).
  • Python 3.12: python -m unittest discover -s tests -t . -v: 121 passed, two Unix-domain-socket tests blocked by PermissionError in the execution environment.
  • git diff --check passes.

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