Skip to content

fix: prevent zombie WebSocket when destroy() called during init#1360

Open
dearlordylord wants to merge 1 commit intopeers:masterfrom
dearlordylord:fix/zombie-websocket-after-destroy
Open

fix: prevent zombie WebSocket when destroy() called during init#1360
dearlordylord wants to merge 1 commit intopeers:masterfrom
dearlordylord:fix/zombie-websocket-after-destroy

Conversation

@dearlordylord
Copy link
Copy Markdown

@dearlordylord dearlordylord commented Mar 14, 2026

When new Peer() is created without an ID, retrieveId() fires an async HTTP request.

If destroy() is called before it resolves, _initialize() runs unconditionally on the destroyed peer, creating a WebSocket that sends heartbeats indefinitely with no event listeners and no API path to close it.

Add a guard in _initialize() to return early if the peer is destroyed or disconnected. Also guard the async error handlers in retrieveId() and listAllPeers() to suppress spurious error events on dead peers.

potentially related to #789

@dearlordylord dearlordylord force-pushed the fix/zombie-websocket-after-destroy branch from f22fd88 to 9eb0599 Compare March 15, 2026 05:39
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