fix(polymarket-us): prevent websocket connect hangs with garbage-collected timeout#1580
Conversation
PR Review: PASS (NOT VERIFIED)What This DoesWraps Polymarket US WebSocket connection setup in a 15s timeout and clears the timer in Blast RadiusPolymarket US WebSocket initialization only: Consumer VerificationBefore (base branch): After (PR branch): Test Results
FindingsNo blocking findings. PMXT Pipeline Check
Semver Impactpatch -- WebSocket reliability fix. RiskThe timeout path does not explicitly close the partially connecting socket; if the underlying SDK continues connecting after the race rejects, it may need follow-up cleanup hardening. |
Description
Fixes #722.
The PolymarketUS WebSocket adapter lacked a connection timeout, meaning network partitions or unreachable endpoints during the TLS/TCP handshake would cause
socket.connect()to hang indefinitely, blockingwatchOrderBook()andwatchTrades().This PR implements the requested timeout but wraps it in a
try/finallyblock withclearTimeout. This ensures that successful connections immediately garbage-collect the timer, preventing dangling callbacks from polluting the Node.js event loop during high-frequency reconnects.