fix(audit): cancel the live-stream reconnect timer on dispose

The onDone handler armed an anonymous 3 s reconnect timer that
nothing could cancel; when the stream closed right before the page
was disposed (no hub, connect ends in onDone instead of onError),
the timer outlived the tree. The a11y suite caught this as the
rare 'Timer is still pending' flake noted in the night log — the
failure reason is now captured and the timer lives in a field that
dispose() cancels.

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
flemming-it 2026-07-18 17:33:11 +02:00
parent ea2cd87b5e
commit 383490027b

View file

@ -81,6 +81,7 @@ class _AuditPageState extends State<AuditPage> {
/// filtering, and the hash-chain ordering exactly as before.
StreamSubscription<AuditEvent>? _eventSub;
Timer? _nudgeDebounce;
Timer? _reconnect;
@override
void initState() {
@ -97,6 +98,7 @@ class _AuditPageState extends State<AuditPage> {
Workspace.instance.removeListener(_onWorkspaceChanged);
_poller?.cancel();
_nudgeDebounce?.cancel();
_reconnect?.cancel();
_eventSub?.cancel();
super.dispose();
}
@ -122,7 +124,12 @@ class _AuditPageState extends State<AuditPage> {
onDone: () {
_eventSub = null;
if (mounted) {
Timer(const Duration(seconds: 3), () {
// Held in a field so dispose() can cancel it an
// anonymous timer here outlives the page when the
// stream closes right before navigation (the a11y
// suite caught this as a pending-timer flake).
_reconnect?.cancel();
_reconnect = Timer(const Duration(seconds: 3), () {
if (mounted && _eventSub == null) _subscribeLive();
});
}