LibreChat/packages/api
Danny Avila 0b8e0fcede
📡 refactor: SSE Connection Settings and Error Handling (#11129)
* 🛜 refactor: SSE Connection Handling in MCP

- Introduced a longer initial handshake timeout for SSE connections to improve reliability through proxies.
- Added standardized request headers for SSE connections to ensure proper handling.
- Implemented a function to extract meaningful error messages from SSE transport errors, addressing common issues like timeouts, connection resets, and DNS failures.
- Enhanced error logging with detailed context to aid in debugging and provide insights into connection issues.

This update aims to improve the robustness and user experience of SSE connections in the MCP.

* chore: Update SSE Connection Headers Documentation

- Clarified the documentation for SSE connection headers by removing unnecessary details and emphasizing the headers that are intentionally excluded.
- Improved readability and conciseness of the comments regarding HTTP/2 connection management.

This change aims to enhance the clarity of the code documentation for better understanding and maintenance.

* refactor: Improved the handling of SSE transport errors by implementing a function to extract meaningful error messages, addressing various scenarios such as timeouts, connection resets, and DNS failures.
- Added comprehensive unit tests for the new error handling function, ensuring robust detection and reporting of common SSE error cases.
- Updated comments in the connection handling code to clarify the merging of headers, emphasizing user-defined overrides.

This update aims to improve the reliability and clarity of error reporting in SSE connections, enhancing the overall user experience.

* refactor: Enhance SSE error message extraction for improved timeout detection

- Updated the `extractSSEErrorMessage` function to include case-insensitive matching for various timeout patterns, including 'ESOCKETTIMEDOUT', 'timed out', 'timeout after', and 'request timeout'.
- Added unit tests to ensure accurate detection of these timeout messages and prevent false positives in unrelated contexts.
- Improved comments for clarity on the timeout detection logic.

This change aims to enhance the reliability of error handling in SSE connections, providing clearer feedback for timeout scenarios.
2025-12-28 12:19:27 -05:00
..
src 📡 refactor: SSE Connection Settings and Error Handling (#11129) 2025-12-28 12:19:27 -05:00
.gitignore 🧠 feat: User Memories for Conversational Context (#7760) 2025-06-07 18:52:22 -04:00
babel.config.cjs 🧠 feat: User Memories for Conversational Context (#7760) 2025-06-07 18:52:22 -04:00
jest.config.mjs 🔄 refactor: MCP Registry System with Distributed Caching (#10191) 2025-10-31 15:00:21 -04:00
package.json 📦 chore: bump MCP SDK to v1.25.1 and fix packages/api ghost dependencies (#11128) 2025-12-28 11:49:41 -05:00
rollup.config.js 🔄 refactor: Migrate Cache Logic to TypeScript (#9771) 2025-10-02 09:33:58 -04:00
tsconfig-paths-bootstrap.mjs 🧠 feat: User Memories for Conversational Context (#7760) 2025-06-07 18:52:22 -04:00
tsconfig.build.json 🧑‍💻 refactor: Secure Field Selection for 2FA & API Build Sourcemap (#9087) 2025-08-15 18:55:49 -04:00
tsconfig.json 🌊 feat: Resumable LLM Streams with Horizontal Scaling (#10926) 2025-12-19 12:14:19 -05:00
tsconfig.spec.json 🧠 feat: User Memories for Conversational Context (#7760) 2025-06-07 18:52:22 -04:00