-
Notifications
You must be signed in to change notification settings - Fork 749
fix: enhanced buffer handling #605
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
Conversation
This enhancement builds upon the existing fix for 'bufio.Scanner: token too long' errors by adding configurable buffer sizes with a much larger default (1MB). Changes: - Add bufferSize field to Stdio struct with 1MB default (vs 4KB default) - Add WithBufferSize() option function for custom buffer configuration - Update constructors to use bufio.NewReaderSize() with configurable buffer - Add GetBufferSize() and SetBufferSize() utility methods - Add comprehensive tests for buffer size configuration and large messages - Add benchmarks for different buffer sizes and message sizes Features: - Backward compatible: existing code automatically gets 1MB buffer - Configurable: users can set custom buffer sizes for specific needs - Efficient: reduces buffer reallocations for large messages - Well-tested: comprehensive test suite including 5MB+ messages Usage: // Default usage (1MB buffer) client := transport.NewStdio("server", env, args...) // Custom buffer for very large responses client := transport.NewStdioWithOptions("server", env, args, transport.WithBufferSize(10 * 1024 * 1024)) // 10MB Fixes large MCP tool responses, base64 content, and verbose error messages that previously caused 'token too long' errors with the default 4KB buffer.
WalkthroughAdds a configurable buffer size to Stdio transport: new DefaultBufferSize constant, option WithBufferSize, getters/setters, and wiring through IO initialization and spawnCommand. Introduces comprehensive tests and benchmarks for buffer configuration and large message handling. No other modules changed. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (3)📓 Common learnings
📚 Learning: 2025-08-08T15:38:52.931Z
Applied to files:
📚 Learning: 2025-08-08T15:37:18.458Z
Applied to files:
🧬 Code graph analysis (2)client/transport/stdio.go (1)
client/transport/stdio_buffer_test.go (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This enhancement builds upon the existing fix for 'bufio.Scanner: token too long' errors by adding configurable buffer sizes with a much larger default (1MB).
Changes:
Features:
Usage:
// Default usage (1MB buffer)
client := transport.NewStdio("server", env, args...)
// Custom buffer for very large responses
client := transport.NewStdioWithOptions("server", env, args,
transport.WithBufferSize(10 * 1024 * 1024)) // 10MB
Fixes large MCP tool responses, base64 content, and verbose error messages that previously caused 'token too long' errors with the default 4KB buffer.
Summary by CodeRabbit
New Features
Tests