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
+2
View File
@@ -23,6 +23,7 @@ export const env = createEnv({
client: {
NEXT_PUBLIC_API_URL: z.string().optional(),
NEXT_PUBLIC_STATIC_WEBSITE_ONLY: z.boolean().optional(),
NEXT_PUBLIC_MAX_STREAM_BUFFER_SIZE: z.coerce.number().int().positive().optional(),
},
/**
@@ -34,6 +35,7 @@ export const env = createEnv({
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
NEXT_PUBLIC_STATIC_WEBSITE_ONLY:
process.env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true",
NEXT_PUBLIC_MAX_STREAM_BUFFER_SIZE: process.env.NEXT_PUBLIC_MAX_STREAM_BUFFER_SIZE,
AMPLITUDE_API_KEY: process.env.AMPLITUDE_API_KEY,
GITHUB_OAUTH_TOKEN: process.env.GITHUB_OAUTH_TOKEN,
},