Bound the relay connect handshake so a fetch can't hang forever
This commit is contained in:
parent
0e70aba755
commit
60f9e4ccfa
3 changed files with 41 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue