fix: make SSE buffer size configurable to prevent overflow during multi-round searches (#664) (#665)

* fix: make SSE buffer size configurable to prevent overflow during multi-round searches (Issue #664)

- Add NEXT_PUBLIC_MAX_STREAM_BUFFER_SIZE environment variable for frontend SSE stream buffer
- Default to 1MB for backward compatibility, users can increase to 5-10MB for large searches
- Enhance error message with actual buffer sizes and guidance on configuration
- Add validation schema in env.js with positive integer requirement
- Document configuration in .env.example with clear examples and use cases

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Willem Jiang
2025-10-27 17:03:38 +08:00
committed by GitHub
parent 83f1334db0
commit ccd7535072
3 changed files with 25 additions and 2 deletions

View File

@@ -41,3 +41,17 @@ NEXT_PUBLIC_API_URL=http://localhost:8000/api
# Github OAuth Token (optional)
GITHUB_OAUTH_TOKEN=xxxx
# Stream Buffer Size Configuration (optional)
# Controls the maximum buffer size for SSE (Server-Sent Events) streams in bytes.
# Default: 1MB (1048576 bytes)
# Increase this if you experience buffer overflow errors during large searches.
# Use cases for increasing:
# - Performing multi-round web searches with large content results
# - Handling responses with many search results or images
# - Systems with sufficient memory to handle larger buffers
# Examples:
# - 5MB: NEXT_PUBLIC_MAX_STREAM_BUFFER_SIZE=5242880
# - 10MB: NEXT_PUBLIC_MAX_STREAM_BUFFER_SIZE=10485760
# Note: Very large buffers may increase memory usage. Start with 5-10MB if needed.
# NEXT_PUBLIC_MAX_STREAM_BUFFER_SIZE=1048576