Skip to content

[Web] WebRTC connection lifecycle — missing timeout, aggressive cleanup, orphaned connections #388

@Flegma

Description

@Flegma

Summary

WebRTC data channel handling has lifecycle issues causing hangs and resource leaks.

Findings

  • Webrtc.ts — promise for data channel has no timeout. If channel never opens, promise hangs indefinitely.
  • Webrtc.ts — dataChannel.onclose calls cleanupPeer() immediately while peer may still be referenced.
  • MatchmakingStore — 5-second timeout resolves outer promise but WebRTC connection continues. No cleanup on timeout.

Impact

Latency checks hang forever on failed connections. Orphaned WebRTC connections accumulate.

Suggested Fix

Add timeout to data channel open promise. Delay peer cleanup for graceful shutdown. Clean up WebRTC on timeout.


Related Issues (WebSocket/Networking Pattern)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-highStability & reliabilityaudit-2026-03From March 2026 codebase auditnetworkingWebSocket, WebRTC, or network issueservice:web5stackgg/web service

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions