[Memory Leak] SSE streaming endpoint lacks disconnect detection and task timeout#2878
[Memory Leak] SSE streaming endpoint lacks disconnect detection and task timeout#2878sanrishi wants to merge 1 commit into
Conversation
- Add _sse_disconnect_guard() helper to detect client drops - Add _check_timeout() for 60s max execution window - Wrap asyncio.sleep() calls with wait_for timeout - Add try/finally cleanup for cancelled generators Fixes ritesh-1918#2868
|
Someone is attempting to deploy a commit to the ritesh Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Target
\�ackend/routers/ai.py\ : Lines 321–471 (\�nalyze_stream\ endpoint)
Vector
Resource Memory Leak (Performance)
Problem
The /ai/analyze_stream\ SSE endpoint creates an async generator that runs indefinitely without:
equest.is_disconnected()\ checks. Abandoned generators hold model references until completion.
Changes
equest.is_disconnected()\ before each yield
Fixes #2868