Skip to content

[flutter_tools] Stop deletion progress status during flutter clean - #192996

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
bkonyi:issue-192531
Sep 18, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
bkonyi:issue-192531

Conversation

@bkonyi

@bkonyi bkonyi commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Ensure deletionStatus.stop() is always called in a finally block around file.deleteSync(recursive: true) in CleanCommand._deleteFile.

Previously, deletionStatus.stop() was only called inside the on FileSystemException catch block, leaving StdoutLogger._status active on successful file deletions. Because StdoutLogger.startProgress ignores new statuses when _status != null and only emits the trailing newline in stop() / cancel(), the first Deleting ... progress status remained unstopped, suppressing all subsequent deletion progress statuses and omitting the trailing newline on exit.

Adds a regression test in packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart verifying that flutter clean stops each deletion progress status and logs every deleted directory.

Fixes #192531

Pre-launch Checklist

Ensure deletionStatus.stop() is always called in a finally block around file.deleteSync(recursive: true) in CleanCommand._deleteFile. Previously, deletionStatus.stop() was only called inside the FileSystemException catch block, leaving the first progress spinner unstopped on successful deletions, suppressing subsequent progress statuses, and omitting the trailing newline on exit.

Fixes flutter#192531
@bkonyi bkonyi added CICD Run CI/CD t: cp-candidate A PR that should be considered for a cherry-pick upon landing. labels Sep 18, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request ensures that the directory deletion progress status is stopped during the clean command execution, even if a FileSystemException is thrown, and adds a test to verify this behavior. The feedback suggests simplifying the nested try-finally block by placing the stop call sequentially in both the try and catch blocks to improve code readability.

Comment thread packages/flutter_tools/lib/src/commands/clean.dart
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 18, 2026
@bkonyi
bkonyi requested a review from srawlins September 18, 2026 15:49
@flutteractionsbot

Copy link
Copy Markdown
Contributor

Failed to create CP due to merge conflicts.
You will need to create the PR manually. See the cherrypick wiki for more info.

@bkonyi bkonyi added cp: beta cherry pick this pull request to beta release candidate branch and removed cp: stable cherry pick this pull request to stable release candidate branch labels Sep 21, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor

Failed to create CP due to merge conflicts.
You will need to create the PR manually. See the cherrypick wiki for more info.

auto-submit Bot pushed a commit that referenced this pull request Sep 28, 2026
…lean (#193110)

This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request)
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

### Issue Link:
#192531

### Impact Description:
Running `flutter clean` leaves the first `Deleting ...` terminal spinner/status active after `build/` is deleted because `deletionStatus.stop()` is only called in the `FileSystemException` catch block instead of a `finally` block. Because `StdoutLogger.startProgress` ignores new progress statuses while an existing status is active and only emits a trailing newline when stopped, subsequent deletion statuses (`.dart_tool/`, `ephemeral/`, etc.) are suppressed and the terminal cursor is left mid-line on exit, making `flutter clean` appear to freeze or break off mid-execution.

*(Cherry-pick note: Rebased/merged onto `flutter-3.49-candidate.0`. Because `flutter-3.49-candidate.0` already includes the modular dependency injection migration for `CleanCommand` (#190742), both `packages/flutter_tools/lib/src/commands/clean.dart` and `packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart` match upstream [#192996](#192996) (`f960c3ae208`) byte-for-byte.)*

### Changelog Description:
[flutter/192531] When running `flutter clean` on all platforms, the deletion progress spinner no longer hangs after deleting the first directory and all cleaned directories are properly reported.

### Workaround:
None for the broken terminal progress output, though `flutter clean` still deletes the directories in the background.

### Risk:
What is the risk level of this cherry-pick?

### Test Coverage:
Are you confident that your fix is well-tested by automated tests?

### Validation Steps:
1. Create or open a Flutter project and build it so `build/` and `.dart_tool/` exist.
2. Run `flutter clean` in an interactive terminal.
3. Verify that each `Deleting ...` progress status completes with an elapsed time and a trailing newline is emitted when the command finishes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp: beta cherry pick this pull request to beta release candidate branch t: cp-candidate A PR that should be considered for a cherry-pick upon landing. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter clean seems to "break off" visually in terminal (PS), unknown if all clean tasks are run.

3 participants