Skip to content

fix(app): cancel HomePage announcement timer on dispose - #14373

Merged
Git-on-my-level merged 3 commits into
mainfrom
task/msd-ui-home-announcement-timer
Sep 17, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
task/msd-ui-home-announcement-timer

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

What changed and why

HomePage scheduled a 2s Future.delayed announcement probe that dispose did not cancel. The callback already checked mounted, but the timer still outlived the State: flutter_test then failed _verifyInvariants, and any missed mounted check would touch a disposed context. The delay is now a Timer cancelled in dispose.

Product invariants affected

none

How it was verified

  • cd app && flutter test test/widgets/home_announcement_timer_test.dart — pumps production HomePage, 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.md
  • Merged into task/msd-ui-b1-chat so B1 no longer pumps fake time around this leak.

Tests

app/test/widgets/home_announcement_timer_test.dart is the regression: old Future.delayed stays pending after dispose and fails the binding invariant. New code cancels the Timer in dispose.

Failure class (fixes)

Failure-Class: new

Failure-class transition narrative

New class FC-timer-after-dispose. Closest existing class is FC-run-loop-timer-outlives-owner, which is a macOS RunLoop.main repeating-timer contract, not Flutter State/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 with Future.delayed, which dispose could not cancel. Coordinator verification: I read the diff (same 2 s delay, now a cancellable Timer cancelled in dispose, mounted re-checked after the await) and the regression test passes.

🤖 Generated with Claude Code

Review in cubic

Git-on-my-level and others added 3 commits September 17, 2026 23:23
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]>
@Git-on-my-level
Git-on-my-level merged commit 1cdf7c6 into main Sep 17, 2026
36 checks passed
@Git-on-my-level
Git-on-my-level deleted the task/msd-ui-home-announcement-timer branch September 17, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant