{"slug": "dart-and-flutter-tests-filling-the-disk-diagnose-and-choose-a-fix-agent-prompt", "title": "Dart and Flutter tests filling the disk: diagnose and choose a fix (agent prompt)", "summary": "A developer published an agent prompt that diagnoses disk-filling by `dart test` and `flutter test`, which compile each test file to 20–30 MiB kernel (.dill) files in the system temp folder. The writeup identifies two causes: package:test 1.32 and earlier retain every kernel file until a run ends (fixed in test 1.33.0), and both runners leave `dart_test.*` and `flutter_tools.*` folders behind after SIGHUP or SIGKILL. It offers six remediation options, from cleaning leftovers and upgrading package:test to relocating TMPDIR or scheduling cleanup, and changes nothing until the user chooses.", "body_md": "Give this file to your coding agent. It explains the problem, checks your machine, and asks you how you want to handle it. It changes nothing until you choose.\n\n`dart test` and `flutter test` compile each test file to a kernel (`.dill`) file in the system temp folder. Two things make that folder grow:\n\n1. **Growth during a run (`dart test`).** In` package:test` 1.32 and earlier (`test_core` 0.6.20 and earlier), the runner keeps every kernel file until the whole run ends. Each one can be 20–30 MiB. A package with 200 test files can hold 7 GiB or more while it runs. Several agents or worktrees running tests at once multiply this. Fixed in`test` 1.33.0 (`test_core` 0.6.21). See[dart-lang/test#2710](https://github.com/dart-lang/test/issues/2710) .\n2. **Leftovers after a killed run (`dart test` and `flutter test`).** Both delete their temp folder when a run finishes, and on Ctrl-C or SIGTERM. Neither cleans up after SIGHUP (the terminal or agent session closed) or SIGKILL (force kill, for example after a timeout). Later runs do not remove these folders. See[dart-lang/test#2711](https://github.com/dart-lang/test/issues/2711) and[flutter/flutter#84094](https://github.com/flutter/flutter/issues/84094) .\n\n| How the run stopped | `dart test` | `flutter test` | \n|---|---|---|\n| Finished, Ctrl-C or SIGTERM | Cleaned up | Cleaned up | \n| Session closed (SIGHUP) | `dart_test.*` left | `flutter_tools.*` left | \n| Force kill (SIGKILL) | `dart_test.*` left | `flutter_tools.*` left | \n\n**Why you may not have the fix yet.** In a pub workspace that includes a Flutter package, `flutter_test` pins `test_api` to an exact version, which caps `package:test`:\n\n| Flutter | Newest `test` | Has fix 1? | \n|---|---|---|\n| 3.50 and earlier | 1.32.x or older | No | \n| 3.51 and later | 1.33.0+ | Yes | \n\nPure Dart packages outside a Flutter workspace can use `test: ^1.33.0` now. Never override `test_api` to get the fix early.\n\nDo not create, edit or delete anything in this step. Report:\n\n- OS and where the system temp folder is (macOS: `getconf DARWIN_USER_TEMP_DIR` ; Linux:`$TMPDIR` or`/tmp` ; Windows:`%TEMP%` ), and how much free space that drive has.\n- Any `dart_test.*` and`flutter_tools.*` folders there: count, total size, newest change time, and whether a running process still uses them.\n- For the current project, the resolved `test_core` version (`pubspec.lock` ) and Flutter version, and whether it has fix 1.\n- Which shells and agents the person uses, and whether any agent runs in a sandbox that limits where it can write.\n- Other drives with more free space, if any.\n\nShow the diagnosis, then offer only the options that fit this machine. Say what each changes and what it does not cover. Wait for the person to choose. They may choose several or none.\n\n- **A. Clean up now.** Remove leftover folders that nothing is using and that have not changed recently. Show the list and get a yes first.\n- **B. Upgrade `package:test`.** Only if the Flutter pin allows` test` 1.33.0 or later. Fixes growth during a run, not leftovers.\n- **C. Move the temp folder to a larger drive.** Set`TMPDIR` in a file every shell reads. Keep a fallback for when the drive is not mounted, because`flutter` fails if`TMPDIR` points to a missing folder. Does not cover programs an app starts without a shell. Sandboxed agents may need the new folder added to their allowed write paths; find their real setting, do not guess.\n- **D. Scheduled cleanup.** A job (launchd, cron, systemd timer or Task Scheduler) that removes only`dart_test.*` and`flutter_tools.*` folders that are stale and not in use. Default to a dry run. Show the script and schedule before installing.\n- **E. Limit parallel runs.** Run fewer test suites at once across agents or worktrees, for example with`--concurrency` or one test run per machine.\n- **F. Do nothing.** Report only.\n\nDo only what the person chose. Back up any file before you edit it. After each change, run one short test and show that the temp files land where expected and are gone when the run finishes. Do not touch the analyzer cache, pub cache, build folders or source files unless the person asks.", "url": "https://wpnews.pro/news/dart-and-flutter-tests-filling-the-disk-diagnose-and-choose-a-fix-agent-prompt", "canonical_source": "https://gist.github.com/leoafarias/d8373e52755724bf98cbf5b40e681b02", "published_at": "2026-11-30 16:27:46+00:00", "updated_at": "2026-12-01 07:43:38.862267+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Dart", "Flutter", "package:test", "test_core", "flutter_test", "dart-lang/test"], "also_reported_by": [], "takeaway": "Upgrading to package:test 1.33.0 (test_core 0.6.21) stops the runner from holding every 20–30 MiB kernel file until a run ends, but SIGHUP and SIGKILL still leave dart_test.* and flutter_tools.* temp folders that need separate cleanup.", "recommendation": {"advice": "Upgrade package:test to 1.33.0 where the Flutter pin allows it, and add a dry-run scheduled job that deletes only stale, unused dart_test.* and flutter_tools.* temp folders.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/dart-and-flutter-tests-filling-the-disk-diagnose-and-choose-a-fix-agent-prompt", "markdown": "https://wpnews.pro/news/dart-and-flutter-tests-filling-the-disk-diagnose-and-choose-a-fix-agent-prompt.md", "text": "https://wpnews.pro/news/dart-and-flutter-tests-filling-the-disk-diagnose-and-choose-a-fix-agent-prompt.txt", "jsonld": "https://wpnews.pro/news/dart-and-flutter-tests-filling-the-disk-diagnose-and-choose-a-fix-agent-prompt.jsonld"}}