Skip to content

fix(proxy): Correctly close connection pipe when dealing with error

Jill requested to merge KokaKiwi/snowflake:fix/proxy--close-pipe into main

This fix is mainly about closing properly the reader side of the pipe used in proxy to transmit data from the WebRTC DataChannel OnMessage listener over to the webRTCConn using it to "copy-loop" with the websocket connection to the relay.

Not closing it properly, for instance on error like "could not dial the relay" (which would happen when one of the relay is down 😛), would cause the pipe not being read and thus, blocking any call on the writer side of it.
This blocking situation would then cause the OnMessage event callback to never return, causing then the webrtc library-suite to utterly fail at closing the connection since the read-loop used internally would be blocked on the onMessage event signalling.

All this contributing to the recent situation of Snowflake proxies going berzerk (huge memory consumption and weird metrics) whenever a relay is down, which would hopefully be fixed by these changes.

Merge request reports