fix(perps): sentry issue improvements#25029
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #25029 +/- ##
==========================================
+ Coverage 79.88% 79.89% +0.01%
==========================================
Files 4231 4245 +14
Lines 108283 109173 +890
Branches 22674 22832 +158
==========================================
+ Hits 86503 87229 +726
- Misses 15722 15886 +164
Partials 6058 6058 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsThis PR makes significant changes to the Perps (Perpetuals) trading functionality, specifically:
All changes are contained within the The SmokePerps tag is the appropriate and only necessary tag because:
|
|



Description
This PR cleans up verbose Sentry error logging in the Perps feature. Many of these errors were logged for debugging connection issues but don't represent actual user-impacting problems. The changes focus on graceful handling during transient states (reconnection, initialization) and fixing a WebSocket race condition.
Key Issues Fixed:
await ensureSubscriptionClient()) to guarantee client availability before use. Throws are preserved as safety assertions - they should never fire with the async gates in place. Exception:restoreSubscriptions()uses graceful return since it's invoked during reconnection when transport readiness is still being established.Technical Changes:
ensureTransportReady()method to HyperLiquidClientService that awaits SDK'stransport.ready()before marking connection as CONNECTEDinitialize()async with 10s timeout for WebSocket handshakehandleConnectionDrop()to await transport ready before restoring subscriptionsrestoreSubscriptions()before re-establishing subscriptionsApproach:
transport.ready()method - no SDK modification requiredrestoreSubscriptions()(legitimate transient state during reconnection)restoreSubscriptions()handles reconnection automaticallyChangelog
CHANGELOG entry: Fixed Perps WebSocket race conditions and error handling during reconnection/initialization states
Related issues
Reduces verbose Sentry logging for:
Note: Event counts in Sentry are inflated due to verbose debug logging during development.
Manual testing steps
Screenshots/Recordings
Before
Verbose Sentry errors logged during WebSocket reconnection and initialization states (these were debug-level issues, not user-impacting)
After
restoreSubscriptions()mechanismPre-merge author checklist
Pre-merge reviewer checklist
Note
Strengthens Perps connection lifecycle and reduces transient Sentry noise.
ensureTransportReady()and makesHyperLiquidClientService.initialize()async; awaitstransport.ready()during init and reconnection; improves health checks and reconnection cleanupHyperLiquidProvider.ensureClientsInitialized()to async with a promise lock; awaits initialization at many read-only call sites; safely awaits pending init intoggleTestnet()anddisconnect()PerpsController.getActiveProviderOrNull()and uses it inPerpsStreamManagerto skip fetches during init/reinitHyperLiquidSubscriptionServicenow awaitsensureSubscriptionClient()and verifies transport readiness inrestoreSubscriptions(); subscriptions re-established only when readystripQuotes, and validates patterns inmarketUtilsWritten by Cursor Bugbot for commit 56c79d8. This will update automatically on new commits. Configure here.