Repository navigation
fix(app): cancel HomePage announcement timer on dispose - #14373
Merged
Merged
Conversation
A 2s Future.delayed survived unmount and failed flutter_test invariants; hold a Timer on the State and cancel it in dispose. Co-authored-by: Cursor <[email protected]>
The HomePage timer widget test added in this PR imports firebase_core_platform_interface/test.dart for setupFirebaseCoreMocks. That package is a transitive dependency of the already-declared firebase_core and does not re-export the test helper, so the analyzer ratchet counted a new depend_on_referenced_packages occurrence (5 found, baseline 4) and Dart Analyze & Tests failed. Declaring it changes no resolved version and adds no package to the tree: pubspec.lock moves the same 5.4.2 from "transitive" to "direct dev". This follows the existing convention in dev_dependencies, where async and stream_channel are declared for the same reason. Failure-Class: none Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
HomePage scheduled a 2s
Future.delayedannouncement probe that dispose did not cancel. The callback already checkedmounted, but the timer still outlived the State: flutter_test then failed_verifyInvariants, and any missedmountedcheck would touch a disposed context. The delay is now aTimercancelled indispose.Product invariants affected
none
How it was verified
cd app && flutter test test/widgets/home_announcement_timer_test.dart— pumps productionHomePage, disposes it, advances 900ms (tab prewarm only), and ends without elapsing the 2s announcement delay. Passes only if that timer was cancelled.scripts/failure-class prepare --pr-body-file .local/pr-body-home-timer.mdtask/msd-ui-b1-chatso B1 no longer pumps fake time around this leak.Tests
app/test/widgets/home_announcement_timer_test.dartis the regression: oldFuture.delayedstays pending after dispose and fails the binding invariant. New code cancels theTimerindispose.Failure class (fixes)
Failure-Class: new
Failure-class transition narrative
New class
FC-timer-after-dispose. Closest existing class isFC-run-loop-timer-outlives-owner, which is a macOS RunLoop.main repeating-timer contract, not FlutterState/Timer/Future.delayed.Part of the mobile self-driving program (App UI lane). Implemented by Cursor
cursor-grok-4.6-high. Found when a contract test needed a 3 s pump to get past it: HomePage scheduled a 2 s delayed announcement check withFuture.delayed, whichdisposecould not cancel. Coordinator verification: I read the diff (same 2 s delay, now a cancellableTimercancelled indispose,mountedre-checked after the await) and the regression test passes.🤖 Generated with Claude Code