-
Notifications
You must be signed in to change notification settings - Fork 49
Fix JSON-RPC pipe reads >64KB by handling short reads #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add _read_exact() method to handle short reads from pipes - Update _read_message() to use _read_exact() for reliable large payload handling - Add comprehensive unit tests for short read scenarios and large payloads Co-authored-by: SteveSandersonMS <[email protected]>
Co-authored-by: SteveSandersonMS <[email protected]>
|
@copilot Re-run python formatter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a critical bug in the JSON-RPC client where reading large responses (>64KB) failed due to Python's read() not guaranteeing to return all requested bytes from pipes. The fix implements a loop-based reading approach that accumulates chunks until all expected bytes are received.
Changes:
- Added
_read_exact()method to handle partial/short reads from pipes - Updated
_read_message()to use_read_exact()instead of directread() - Added comprehensive unit tests covering various payload sizes and edge cases
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/copilot/jsonrpc.py | Added _read_exact() method that loops until all requested bytes are read, updated _read_message() to use it |
| python/test_jsonrpc.py | New test file with mock classes (MockProcess, ShortReadStream) and comprehensive test coverage for the fix including 64KB boundary cases, large payloads, EOF handling, and sequential messages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: SteveSandersonMS <[email protected]>
Plan to fix JSON-RPC large payload issue
_read_exact()helper method injsonrpc.py_read_message()to use_read_exact()for reading contentOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.