mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix(mobile): stabilize relay retry lifecycle
Avoid duplicate disconnect callbacks during authentication and invalidate deliberate reconnect callbacks before replacing the socket. Co-authored-by: npub1ux8n2yfs8qfvgd75s7kyhar2mztac355v6vmrz4juc9l3msw4pgstums9e <e18f3511303812c437d487ac4bf46ad897dc46946699b18ab2e60bf8ee0ea851@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1ux8n2yfs8qfvgd75s7kyhar2mztac355v6vmrz4juc9l3msw4pgstums9e <e18f3511303812c437d487ac4bf46ad897dc46946699b18ab2e60bf8ee0ea851@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
parent
336a1a0b7a
commit
024476edc4
@@ -317,6 +317,7 @@ class RelaySessionNotifier extends Notifier<SessionState> {
|
||||
/// Force a reconnect (e.g., returning from background).
|
||||
Future<void> reconnect() async {
|
||||
_reconnectTimer?.cancel();
|
||||
++_connectionGeneration;
|
||||
await _socket?.disconnect();
|
||||
_resetReconnectBudget();
|
||||
final config = ref.read(relayConfigProvider);
|
||||
|
||||
@@ -102,14 +102,18 @@ class RelaySocket {
|
||||
_subscription = _channel!.stream.listen(
|
||||
_handleRawMessage,
|
||||
onError: (Object error) {
|
||||
final awaitingAuth =
|
||||
_authCompleter != null && !_authCompleter!.isCompleted;
|
||||
_failAuth(error);
|
||||
_resetConnection();
|
||||
_onDisconnected(error);
|
||||
if (!awaitingAuth) _onDisconnected(error);
|
||||
},
|
||||
onDone: () {
|
||||
final awaitingAuth =
|
||||
_authCompleter != null && !_authCompleter!.isCompleted;
|
||||
_failAuth(null);
|
||||
_resetConnection();
|
||||
_onDisconnected(null);
|
||||
if (!awaitingAuth) _onDisconnected(null);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user