Skip to content

[flutter_tools] Do not hang when file locking is unsupported by the filesystem - #192821

Draft
bkonyi wants to merge 3 commits into
flutter:masterfrom
bkonyi:issue-192802
Draft

bkonyi wants to merge 3 commits into
flutter:masterfrom
bkonyi:issue-192802

Conversation

@bkonyi

@bkonyi bkonyi commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Description

On filesystems where advisory locking is not supported (such as macOS SMB/smbfs network mounts), RandomAccessFile.lockSync throws a FileSystemException with an OS error code indicating that locking is unsupported (e.g. ENOTSUP / 45, ENOLCK / 77, or EINVAL / 22).

Previously, FileSystemLocking.runLocked only caught UnimplementedError and UnsupportedError to bypass locking. Consequently, native FileSystemException errors on unsupported filesystems were treated as lock contention, causing Flutter commands (such as Swift Package Manager plugin resolution) to hang indefinitely in a 50ms polling loop with:

Waiting for another flutter command to release the Swift Package Manager lock...

This change inspects the OS error code in runLocked. If the error code indicates that locking is unsupported rather than genuine lock contention (EAGAIN, EACCES, Windows sharing/lock violations), runLocked logs the exception to trace and proceeds to execute the scope without holding the lock.

Related Issues

Fixes #192802

Tests

  • Added unit tests in test/general.shard/base/file_system_test.dart for all unsupported error codes across macOS, Linux, and Windows, scope exception propagation, and contention retries.
  • Added regression test in test/general.shard/macos/swift_package_manager_test.dart verifying that generatePluginsSwiftPackage proceeds without locking or hanging on macOS ENOTSUP (45).

…ilesystem

On filesystems where advisory locking is not supported (such as macOS
SMB/smbfs mounts), `RandomAccessFile.lockSync` throws a `FileSystemException`
with an OS error code indicating that locking is unsupported (e.g. `ENOTSUP` / 45,
`ENOLCK` / 77, or `EINVAL` / 22).

Previously, `FileSystemLocking.runLocked` only caught `UnimplementedError`
and `UnsupportedError` to bypass locking. As a result, native `FileSystemException`
errors on unsupported filesystems were treated as lock contention, causing
Flutter commands (such as Swift Package Manager plugin resolution) to retry
indefinitely in a 50ms polling loop with:
"Waiting for another flutter command to release the Swift Package Manager lock..."

This change inspects the OS error code in `runLocked`. If the error code indicates
an error other than genuine lock contention (`EAGAIN`, `EACCES`, Windows
sharing/lock violations), `runLocked` logs the exception to trace and proceeds
with executing the scope without holding the lock.

Fixes flutter#192802
@bkonyi bkonyi added the CICD Run CI/CD label Sep 15, 2026
@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. a: desktop Running on desktop team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD team-ios Owned by iOS platform team team-macos Owned by the macOS platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Waiting for another flutter command to release the Swift Package Manager lock..." on SMB share on MacOS

1 participant