Repository navigation
fix(app): cancel the HomePage tab prewarm timers on dispose - #14406
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]>
The 350ms-staggered IndexedStack prewarm Timers survived unmount the same way the announcement delay did. Hold them on the State and cancel in dispose. Failure-Class: FC-timer-after-dispose Co-authored-by: Cursor <[email protected]>
Two conflicts, both resolved mechanically and verified rather than assumed: app/lib/pages/home/page.dart — both hunks are purely additive on this side (the _prewarmTimers list and its dispose loop) with an empty origin/main side, so this branch's lines are kept. A script resolved only blocks whose main side was empty and would have refused any block where both sides had content. app/test/widgets/home_announcement_timer_test.dart — this side is a strict superset: it carries main's 'announcement delay is cancelled on dispose' test plus 'tab prewarm timers are cancelled on dispose'. Confirmed by comparing the test names on both sides before taking ours. Both tests pass after the merge. Committed with OMI_SKIP_WEB_FORMAT=1. The pre-commit hook refuses to run a floating prettier because the pinned 2.8.8 is not installed in web/app, and it warns that a floating version reformats files into a shape CI rejects. All 11 staged web files are byte-identical to origin/main — they arrive through this merge and are already formatted there — so there is nothing for the formatter to change, and the CI formatting check still runs. 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 still armed one
Timerper non-selected IndexedStack tab (350ms + n×180ms) and never cancelled them. That is the same class as #14373: work scheduled onHomePagethat outlivesdisposeand fails flutter_test_verifyInvariants. Hold the timers on the State and cancel them indispose.Product invariants affected
none
How it was verified
TZ=UTC bash app/test.sh test/widgets/home_announcement_timer_test.dart --name 'HomePage tab prewarm timers are cancelled on dispose'failed withA Timer is still pending even after the widget tree was disposedand dumped the 350/530/710ms timers created in_prewarmRemainingTabs.All tests passed!TZ=UTC bash app/test.shmake preflightdart format --line-length 120on the two touched Dart filesTests
app/test/widgets/home_announcement_timer_test.dart— newHomePage tab prewarm timers are cancelled on dispose. Disposes without elapsing 350ms so leftover prewarm timers fail_verifyInvariants. A further unregistered HomePage timer that is still pending at test end fails the same way. Duration.zero work that fires in the 1ms Upgrader flush would not; asserting list membership itself needs C1CaptureLifetime, which this lane does not have.Failure class (fixes)
Failure-Class: FC-timer-after-dispose
Coordinator notes
Stacked on #14373, and it carries that PR's
firebase_core_platform_interfacedev-dependencyfix merged in, so its own
Dart Analyze & Testscan pass the analyzer ratchet.Two corrections the builder made to the brief it was given, both right and both worth
recording: the four prewarm delays are 350/530/710/890 ms but
_prewarmRemainingTabsskipsthe selected slot, so the default home tab arms three, not four. And the new test catches a
fifth unregistered
Timeronly because any leftover pending timer fails the invariant at testend; it does not assert list membership, and it would need
CaptureLifetime(a differentlane's unmerged file) to do that or to catch a
Duration.zerotimer firing inside the 1 msUpgrader flush. The builder said so rather than faking a source scrape, which is the right
answer.
Found while in this file and deliberately not fixed here, to keep the diff to timer
lifecycle:
_HomePageProductState.initStatedoes not re-checkmountedafterawait Permission.notification.isGranted. That is a real instance of the async-lifecycleclass this program exists to close, and it gets its own PR rather than riding along in this
one. Roughly ten other post-frame callbacks in this file do re-check
mounted; theFuture.delayed(Duration.zero)inbuildon reconnect is uncancelled but its callback checksmounted. There is noTimer.periodicin the file.Two tooling defects surfaced by this work, neither of which this PR changes:
scripts/failure-class preparedid not demand a new class, but it reported three unrelatedadvisory hits because
FC-timer-after-dispose.jsonuses prefix hints such asapp/lib/pages/home/thatfnmatchdoes not treat as globs — it needsapp/lib/pages/home/**.make preflightis hardcoded toorigin/main, so on a stacked branch it failsinstance_fix_mutates_registrybecause the stacked range still contains the parent's newfailure-class definition. Against the stacked parent it is green: 14 checks in 15.19 s.
🤖 Generated with Claude Code