Writing
Mobile English

Your Flutter Tests Are Not Slow - They Are Deadlocked

A CI job that hangs for 45 minutes is a test that failed with no name. Patterns that deadlock the Flutter test isolate, and how to catch them.

  • Published
  • 1 min read

The worst CI failure is not red. It is the job that sits at 43 minutes of a 45-minute timeout, says nothing, and then dies as “cancelled”. I had no idea which test did it, so I re-ran it. The pipeline was now a slot machine.

The usual suspects

Most Flutter CI hangs are one of these:

  • await on a real timer inside testWidgets - fake async never advances, the future never completes.
  • A Completer that only completes in a code path your mock skipped.
  • pumpAndSettle on an animation that never settles (looping spinners are the classic) - fast to fail in a widget test, ten real minutes per call under integration_test.
  • Platform channel calls with no mock handler - the message never comes back.
dart
testWidgets('sync page', (tester) async {
  await tester.pumpWidget(const SyncPage());
  // the mock never completes syncDone, and real-async time has no timeout
  await tester.runAsync(() => syncDone.future);
});

Turn a hang into a named failure

The fix is procedural, not heroic: wrap suites with a watchdog that fails fast and prints the test name. A 45-minute silent hang becomes a 30-second failure that says sync page: timed out waiting for syncDone.

Update, November 2026: the watchdog is now part of tarpit. dart run tarpit points at the test lines that will stall, and importing package:tarpit/flutter_test.dart instead of flutter_test fails a stalled testWidgets with a reason.

Fixing the bug is one job; fixing the feedback loop is the one that keeps paying - a CI you trust is a CI you actually ship from.