Repository navigation
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtriaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
Description
Description
This is the central tracking ticket for the global FileSystem Robustness Initiative in flutter_tools.
Rather than maintaining flaky, repetitive try-catch structures and defensive existence checking at dozens of local call-sites throughout the codebase (which fail frequently and populate our top crash metrics), we should harden the foundational filesystem wrapper ErrorHandlingFileSystem (defined in error_handling_io.dart) to globally protect the CLI tool from all transient, permission, and missing-entity filesystem exceptions.
Root Causes & Gaps Addressed:
This unified initiative systematically closes the following critical gaps inside packages/flutter_tools/lib/src/base/error_handling_io.dart:
- Omission of Async Operations (Cures Rank 9):
ErrorHandlingFileandErrorHandlingDirectorydo not override and wrap basic asynchronous/read operations (such asreadAsString(),exists(),listSync()). Any permission or locking errors thrown during these calls bubble up raw and crash the tool. - Missing Missing-Entity Handling (Cures Rank 7 & Rank 5):
The exception handlers (_handlePosixExceptionand_handleWindowsException) do not intercept missing-file errors (POSIXENOENT[2], WindowsERROR_FILE_NOT_FOUND[2] andERROR_PATH_NOT_FOUND[3]). Consequently, missing files throw rawPathNotFoundExceptions rather than exiting gracefully. - Windows File Sharing Lock Violations (Cures Rank 8):
Antivirus scanners, OneDrive sync engines, and background IDE indexing daemons frequently place transient sharing locks on intermediate files insidebuild/or.dart_tool/on Windows. This throws aPathAccessException(OS Error 32 / 5). We currently have no retry backoff strategy to handle these transient locks.
Expected Resilient Behavior:
- Global Missing-Entity Mapping: If a file is missing, the tool should print a clean, user-friendly error explaining the situation (suggesting running
flutter clean) and terminate cleanly viaToolExitrather than throwing raw stack traces. - Windows Locking Retry Backoff: When a transient sharing violation (OS Error 32 or 5) is encountered on Windows,
ErrorHandlingFileSystemshould automatically wait a few milliseconds and retry up to 5 times, letting the background antivirus or indexer release the lock and successfully completing the build rather than crashing. - Full Async Wrapping: All asynchronous operations on files and directories are wrapped cleanly, ensuring no raw filesystem exceptions escape unhandled out of asynchronous zones.
Proposed Solution
- Flesh out
ErrorHandlingFile,ErrorHandlingDirectory, andErrorHandlingLinkwith exhaustive overrides for all interface methods, wrapping them in_run/_runSync. - Update
_handlePosixExceptionto map code2(enoent). - Update
_handleWindowsExceptionto map codes2(kFileNotFound) and3(kPathNotFound). - Implement an automated exponential backoff retry loop inside the
_run/_runSyncexecution wrappers for Windows lock codes (5,32,33,1224).
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listteam-toolOwned by Flutter Tool teamOwned by Flutter Tool teamtriaged-toolTriaged by Flutter Tool teamTriaged by Flutter Tool team
Activity
[-][Tool Robustness] Globally handle missing filesystem entities (ENOENT / PathNotFound) inside ErrorHandlingFileSystem[/-][+][Tool Robustness] Implement global file-system exception mapping and retry policy in ErrorHandlingFileSystem[/+][tool] Improve global filesystem and symlink robustness on Windows, m…
[tool] Improve global filesystem and symlink robustness on Windows, m…
[tool] Improve global filesystem and symlink robustness on Windows, m…
[tool] Improve global filesystem and symlink robustness on Windows, m…
[flutter_tools] Use `ErrorHandlingFileSystem.deleteIfExists` for `IOS…