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:
parent
ea2cd87b5e
commit
383490027b
1 changed files with 8 additions and 1 deletions
|
|
@ -81,6 +81,7 @@ class _AuditPageState extends State<AuditPage> {
|
||||||
/// filtering, and the hash-chain ordering exactly as before.
|
/// filtering, and the hash-chain ordering exactly as before.
|
||||||
StreamSubscription<AuditEvent>? _eventSub;
|
StreamSubscription<AuditEvent>? _eventSub;
|
||||||
Timer? _nudgeDebounce;
|
Timer? _nudgeDebounce;
|
||||||
|
Timer? _reconnect;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -97,6 +98,7 @@ class _AuditPageState extends State<AuditPage> {
|
||||||
Workspace.instance.removeListener(_onWorkspaceChanged);
|
Workspace.instance.removeListener(_onWorkspaceChanged);
|
||||||
_poller?.cancel();
|
_poller?.cancel();
|
||||||
_nudgeDebounce?.cancel();
|
_nudgeDebounce?.cancel();
|
||||||
|
_reconnect?.cancel();
|
||||||
_eventSub?.cancel();
|
_eventSub?.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +124,12 @@ class _AuditPageState extends State<AuditPage> {
|
||||||
onDone: () {
|
onDone: () {
|
||||||
_eventSub = null;
|
_eventSub = null;
|
||||||
if (mounted) {
|
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();
|
if (mounted && _eventSub == null) _subscribeLive();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue