Skip to content

fix: WebSocket reconnect loop causing memory leak#4

Open
neavra wants to merge 1 commit intoFrondEnt:mainfrom
neavra:fix/websocket-reconnect-loop
Open

fix: WebSocket reconnect loop causing memory leak#4
neavra wants to merge 1 commit intoFrondEnt:mainfrom
neavra:fix/websocket-reconnect-loop

Conversation

@neavra
Copy link

@neavra neavra commented Feb 17, 2026

When a WebSocket connection drops, both error and close events fire, each calling scheduleReconnect(). Since terminate() also triggers close, you get 2 reconnect timers instead of 1. After repeated disconnects this could compound exponentially (2→4→8→16...), potentially spawning many parallel connections.

I believe this may be causing memory/CPU spikes in long-running processes, though I haven't confirmed with profiling. Either way, this is a good defensive fix to prevent duplicate reconnect timers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant