fix(websocket): declare ping support ref for type safety

This commit is contained in:
Nyk 2026-03-05 11:21:27 +07:00
parent 4e3b52c06c
commit 99833f5c53
1 changed files with 3 additions and 0 deletions

View File

@ -59,6 +59,8 @@ export function useWebSocket() {
const pingCounterRef = useRef<number>(0)
const pingSentTimestamps = useRef<Map<string, number>>(new Map())
const missedPongsRef = useRef<number>(0)
// Compat flag for gateway versions that may not implement ping RPC.
const gatewaySupportsPingRef = useRef<boolean>(true)
const {
connection,
@ -116,6 +118,7 @@ export function useWebSocket() {
pingIntervalRef.current = setInterval(() => {
if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN || !handshakeCompleteRef.current) return
if (!gatewaySupportsPingRef.current) return
// Check missed pongs
if (missedPongsRef.current >= MAX_MISSED_PONGS) {