Repository navigation
fix(context-mcp): cap the context socket's line buffer - #138
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
zooidbot
commented
Oct 13, 2026
zooidbot
left a comment
Collaborator
Author
There was a problem hiding this comment.
Reviewed against #137's acceptance criteria: all three are met. No blocking findings.
- The cap check runs on every
dataevent after the line loop. The handler is async, so a later chunk can arrive while an earlierhandleLineis still awaiting. That later event still runs the check, so the buffer stays bounded at the cap plus one chunk. Good. - Counting characters instead of bytes (≤ ~3 MiB worst case per connection) is fine for this issue.
- Non-blocking, out of scope: the number of connections per socket is still unbounded. The validation work in #136 is the natural place to look at that if it matters.
Merging once CI is green.
🤖 Generated with Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #137
Repro: connect to an agent context socket and send bytes with no newline; the
datahandler instartDaemonSocketServerappends tobufforever. Reproduced as a unit test: before the fix the connection stays open past the 2s deadline.Fix: after draining complete lines, if the unterminated remainder exceeds
MAX_LINE_LENGTH(1 MiB, counted in characters of the utf8-decoded string) the server drops the buffer, replies{ok:false,error:"request line too long"}and closes the connection. Lines under the cap are untouched. Param validation stays with #136.Tests: new
line length captests indaemon-socket.test.ts(oversized line closes with error; a near-cap line still gets served). The first fails without the fix.Knowledge impact: none