fix(test): drop eager connectivity listener in MutationReplayer
ref.listen(connectivityProvider, …) at start-time mounted the StreamProvider immediately, which kicked off checkConnectivity() with a 2s timeout. In tests that never reach the auth state (smoke_test cold-launch path), that Timer leaked past widget tree dispose and tripped the still-pending-timer assertion. Drop the edge trigger — the 3s initial + 1min periodic + post- enqueue nudge already cover the drain paths. Worst case on reconnect is ~60s extra latency before the queue drains, which is acceptable for an offline-resilience layer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+6
-11
@@ -38,7 +38,6 @@ import '../playlists/playlists_provider.dart' show playlistsApiProvider;
|
|||||||
import '../quarantine/quarantine_provider.dart' show quarantineApiProvider;
|
import '../quarantine/quarantine_provider.dart' show quarantineApiProvider;
|
||||||
import '../requests/requests_provider.dart' show requestsApiProvider;
|
import '../requests/requests_provider.dart' show requestsApiProvider;
|
||||||
import 'audio_cache_manager.dart' show appDbProvider;
|
import 'audio_cache_manager.dart' show appDbProvider;
|
||||||
import 'connectivity_provider.dart';
|
|
||||||
import 'db.dart';
|
import 'db.dart';
|
||||||
|
|
||||||
/// Stable kind constants. Each controller emits one of these via
|
/// Stable kind constants. Each controller emits one of these via
|
||||||
@@ -111,16 +110,12 @@ class MutationReplayer {
|
|||||||
// from a prior session that died offline. 3s lets the auth +
|
// from a prior session that died offline. 3s lets the auth +
|
||||||
// server-url + dio providers finish their async warmup.
|
// server-url + dio providers finish their async warmup.
|
||||||
_initialTimer = Timer(const Duration(seconds: 3), drain);
|
_initialTimer = Timer(const Duration(seconds: 3), drain);
|
||||||
|
// Periodic ticker is the only reconnect signal. We previously had
|
||||||
// Drain on every connectivity emission that resolves to online.
|
// a ref.listen(connectivityProvider, …) edge trigger here, but
|
||||||
// ref.listen fires on changes after subscription; we don't get
|
// subscribing at start-time eagerly mounted the connectivity
|
||||||
// the initial value, but the Timer above + the periodic poll
|
// StreamProvider and leaked its initial-timeout Timer through
|
||||||
// cover that.
|
// tests that never reach the auth state. The drain() loop itself
|
||||||
_ref.listen(connectivityProvider, (prev, next) {
|
// gates on connectivity via the .future read below.
|
||||||
final isOnline = next.value ?? false;
|
|
||||||
if (isOnline) unawaited(drain());
|
|
||||||
});
|
|
||||||
|
|
||||||
_intervalTimer = Timer.periodic(_interval, (_) => drain());
|
_intervalTimer = Timer.periodic(_interval, (_) => drain());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user