Bound the relay connect handshake so a fetch can't hang forever

This commit is contained in:
randogoth 2026-07-05 16:50:28 +03:00
parent 0e70aba755
commit 60f9e4ccfa
3 changed files with 41 additions and 1 deletions

View file

@ -9,11 +9,15 @@ final class FakeRelayConnection implements RelayConnection {
bool isConnected = false;
bool autoRespond = true;
bool throwOnConnect = false;
// When set, connect() never completes simulates a handshake that hangs
// (accepted socket, no WebSocket upgrade).
bool hangOnConnect = false;
void Function(String subId)? onReq;
@override
Future<void> connect() async {
if (throwOnConnect) throw Exception('connection failed');
if (hangOnConnect) await Completer<void>().future;
isConnected = true;
}