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:
npub1ux8n2yfs8qfvgd75s7kyhar2mztac355v6vmrz4juc9l3msw4pgstums9e
2026-07-14 11:42:29 -07:00
parent 336a1a0b7a
commit 024476edc4
2 changed files with 7 additions and 2 deletions
@@ -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);
+6 -2
View File
@@ -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);
},
);