fix(chat): forward and log streaming errors with details - #521
Conversation
- Add streaming error tracking variable to monitor errors during stream processing - Forward streaming errors to clients via SSE with detailed error information - Mark logs as errored when streaming errors occur with comprehensive error details - Include error status code (500), status text, and actual error message in logs - Ensure graceful error handling even if SSE forwarding fails - Maintain consistent error format across the system
WalkthroughThe streaming handler in the chat completions endpoint was updated to explicitly track and report streaming errors. A new variable captures streaming errors, sends structured SSE error events to the client, and logs error details. The control flow for cancellation and normal completion remains unchanged. Additionally, an end-to-end test was enhanced to assert that no error details are present in successful logs. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (4)**/*.{js,jsx,ts,tsx}📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Files:
**/*.{js,ts}📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Files:
{apps/api,apps/gateway,packages/db}/**/*.ts📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit Inference Engine (.cursor/rules/general.mdc)
Files:
🧬 Code Graph Analysis (1)apps/gateway/src/api.e2e.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Added proper assignment of parsing errors to `streamingError` in chat logic. This helps in identifying and debugging JSON parsing issues in streaming responses.
Forward streaming errors to clients via SSE and log them with detailed error information.
Previously, streaming errors were only logged to the console, making them invisible to clients and difficult to track in logs. This change ensures errors are properly communicated to the client and recorded for debugging and monitoring.
Open in Web • Open in Cursor
Learn more about Background Agents
Summary by CodeRabbit