Improve WebSocket error handling and connection diagnostics#621
Improve WebSocket error handling and connection diagnostics#621marcodejongh wants to merge 3 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Claude Review✅ Ready to merge - Minor issues noted below, but nothing blocking. Issues
DocumentationThe PR adds error handling improvements to the WebSocket client documented in |
Claude Review✅ Ready to merge - Well-structured error handling improvements with good test coverage. Minor Issues
DocumentationThe changes add error handling features to the WebSocket client documented in |
Add proper error handling for WebSocket connection failures, particularly the "invalid origin" error that occurs on some browsers (especially Safari/ WebKit on iOS via DuckDuckGo Mobile). This error can be caused by: - Browser privacy/tracking protection blocking WebSocket connections - Network issues during WebSocket handshake - CORS configuration issues Changes: - Add wrapped WebSocket implementation with early error handlers to catch connection failures before graphql-ws sets up its handlers - Skip retry attempts for origin/CORS related errors since they won't resolve without configuration changes - Add Sentry beforeSend filter to prevent these known connection errors from cluttering error tracking - Improve logging with more context for origin-related failures https://claude.ai/code/session_014RG7hQPmmTu3acu8W2ApKN
Address code review feedback: - Extract shared error patterns to packages/web/app/lib/websocket-errors.ts to avoid duplication between graphql-client.ts and instrumentation-client.ts - Make error filtering more specific: only filter WebSocket-specific errors, not generic network errors like "failed to fetch" that could indicate legitimate API failures - Add unit tests for error detection utilities (isOriginError, isWebSocketLifecycleError, shouldFilterFromSentry) https://claude.ai/code/session_014RG7hQPmmTu3acu8W2ApKN
Document the error handling and filtering behavior for WebSocket connections, including which errors are filtered from Sentry and why. https://claude.ai/code/session_014RG7hQPmmTu3acu8W2ApKN
88a0e7f to
45c7618
Compare
Claude Review✅ Ready to merge - No significant issues found. The PR adds well-structured WebSocket error handling with proper test coverage. The documentation has been updated appropriately in |
Summary
This PR enhances error handling for GraphQL WebSocket connections and improves error reporting by adding better diagnostics for origin/CORS issues and filtering out non-actionable connection errors from error tracking.
Key Changes
GraphQL Client Improvements (
graphql-client.ts)isOriginError()utility andORIGIN_ERROR_PATTERNSto identify browser-specific CORS/origin validation failurescreateWrappedWebSocket()that extends the native WebSocket with early error handlers to catch connection failures before graphql-ws sets up its handlersshouldRetry()to skip retries on origin/CORS errors since these won't resolve without configuration changesError Tracking Improvements (
instrumentation-client.ts)shouldFilterError()utility andFILTERED_ERROR_PATTERNSto identify expected connection errorsImplementation Details
https://claude.ai/code/session_014RG7hQPmmTu3acu8W2ApKN