Skip to content

[stable] [flutter_tools] Handle target VM filesystem errors in DevFS.create - #196895

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.50-candidate.0from
flutteractionsbot:cp-stable-95d983376889c7e9157ce3422fb60359d5d12a2f
Nov 18, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.50-candidate.0from
flutteractionsbot:cp-stable-95d983376889c7e9157ce3422fb60359d5d12a2f

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Cherry-pick of #196234.

This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

Issue Link:

#196118

Impact Description:

This issue impacts local development (flutter run and flutter attach), not shipped production apps. When the target Dart VM cannot create a temporary DevFS directory (for example, due to restricted TEMP permissions on Windows or full disk space on a simulator or desktop host), the VM service returns RPCError -32603. DevFS.create rethrows that error unhandled and triggers a P1 top-crasher report in flutter_tools instead of reporting the underlying OS filesystem failure.

Changelog Description:

[flutter/196118] When the target device or host temporary directory is inaccessible or full during debug launch (most commonly on Windows and iOS Simulator), flutter run and flutter attach crash with an unhandled RPCError.

Workaround:

Ensure the temporary directory used by the target device or host (%TEMP% / %LOCALAPPDATA%\Temp on Windows, or TMPDIR on macOS, Linux, and simulators) exists, is writable by the current user, and has free disk space.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

  1. Run flutter test test/general.shard/devfs_test.dart in packages/flutter_tools and verify all tests pass, including target VM filesystem RPCError translation on initial create() and retry after destroy(), plus rethrowing non-filesystem -32603 errors.
  2. Create a read-only temporary directory (mkdir /tmp/readonly_tmp && chmod 0555 /tmp/readonly_tmp), launch flutter_tester with TMPDIR=/tmp/readonly_tmp, and run BOT=true flutter attach --debug-uri=<vm-service-uri>. Verify flutter attach exits with Error initializing DevFS: DevFSException(Failed to create DevFS on device, PathAccessException: ...) instead of an unhandled RPCError crash report.

…lutter#196234)

Previously, `DevFS.create` only translated VM service disconnection RPC
errors (`kServiceDisappeared`, `kConnectionDisposed`) and retried `1001`
(`kFileSystemAlreadyExists`), rethrowing all other `RPCError` instances
as unhandled tool crashes. When the target Dart VM failed to create a
temporary directory during `_createDevFS` (for example due to a
read-only, inaccessible, or full `TMP`/`TEMP`/`TMPDIR` directory on the
target machine or device), the VM service returned `RPCError` `-32603`
(`kInternalError`) wrapping a `dart:io` `FileSystemException`
(`PathAccessException`, `PathNotFoundException`, `PathExistsException`,
or `FileSystemException`). That unhandled `RPCError` escaped
`HotRunner._attach` / `HotRunner.run` and triggered crash reporting.

Translate `-32603` `RPCError` responses whose `details` wrap a target VM
`FileSystemException` into `DevFSException('Failed to create DevFS on
device', fileSystemError)` in `DevFS.create` (including on the retry
attempt after `destroy()`), keeping `DevFSException.message` PII-free
for `GitHubTemplateCreator.sanitizedCrashException` while surfacing the
underlying OS filesystem error in `DevFSException.error` and
`DevFSException.toString()`. Non-filesystem `-32603` internal VM errors
continue to rethrow to crash reporting. Also type `DevFSException.error`
as `Object?` and omit `null` optional fields in
`DevFSException.toString()`.

Reproduced against `flutter_tester` launched with a read-only
`TMPDIR=/tmp/flutter_devfs_repro_readonly` (`chmod 0555`) and `BOT=true`
on `flutter attach`:

Previous output:
```
_createDevFS: (-32603) Internal error
_createDevFS: Unexpected exception:PathAccessException: Creation of temporary directory failed, path = '/tmp/flutter_devfs_repro_readonly' (OS Error: Permission denied, errno = 13)
#0      _checkForErrorResponse (dart:io/common.dart:58:9)
flutter#1      _Directory.createTemp.<anonymous closure> (dart:io/directory_impl.dart:163:7)
<asynchronous suspension>
flutter#2      createTempDirCallback (dart:vmservice_io:101:16)
<asynchronous suspension>
flutter#3      DevFS._createDevFS (dart:_vmservice/devfs.dart:197:21)
<asynchronous suspension>
flutter#4      VMService._routeRequestImpl (dart:_vmservice:759:16)
<asynchronous suspension>
flutter#5      VMService.routeRequest (dart:_vmservice:726:22)
<asynchronous suspension>
flutter#6      WebSocketClient.post (dart:vmservice_io/vmservice_server.dart:64:3)
<asynchronous suspension>

#0      new _OutstandingRequest (package:vm_service/src/vm_service.dart:280:34)
flutter#1      VmService._call.<anonymous closure> (package:vm_service/src/vm_service.dart:1962:25)
flutter#2      VmService._call (package:vm_service/src/vm_service.dart:1974:8)
flutter#3      VmService.callServiceExtension (package:vm_service/src/vm_service.dart:1913:14)
flutter#4      FlutterVmService.createDevFS (package:flutter_tools/src/vmservice.dart:1060:20)
flutter#5      DevFS.create (package:flutter_tools/src/devfs.dart:497:61)
flutter#6      FlutterDevice.setupDevFS (package:flutter_tools/src/resident_runner.dart:331:19)
flutter#7      HotRunner._initDevFS (package:flutter_tools/src/run_hot.dart:473:23)
flutter#8      HotRunner._attach (package:flutter_tools/src/run_hot.dart:280:41)
<asynchronous suspension>
flutter#9      AttachCommand._attach (package:flutter_tools/src/commands/attach.dart:296:24)
<asynchronous suspension>
flutter#10     AttachCommand.runCommand (package:flutter_tools/src/commands/attach.dart:250:7)
<asynchronous suspension>
flutter#11     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:876:27)
<asynchronous suspension>
flutter#12     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#13     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
flutter#14     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:689:9)
<asynchronous suspension>
flutter#15     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#16     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:619:5)
<asynchronous suspension>
flutter#17     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:379:5)
<asynchronous suspension>
flutter#18     run.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:419:19)
<asynchronous suspension>
flutter#19     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#20     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#21     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#22     main (package:flutter_tools/executable.dart:133:3)
<asynchronous suspension>

Feature flags enabled: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration, enable-riscv64, enable-hcpp
```

Current output:
```
Error initializing DevFS: DevFSException(Failed to create DevFS on device, PathAccessException: Creation of temporary directory failed, path = '/tmp/flutter_devfs_repro_readonly' (OS Error: Permission denied, errno = 13))
```

Fixes flutter#196118
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Nov 18, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

@bkonyi please fill out the PR description above, afterwards the release team will review this request.

@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Nov 18, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Nov 18, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@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 updates DevFS.create to handle internal RPC errors from the target VM, parsing filesystem exceptions and translating them into DevFSException with path-bearing OS error details. It also refactors the creation loop to handle retries and adds corresponding unit tests to verify this behavior. Additionally, DevFSException.toString is updated to format its components, and FakeRPCError is enhanced to support optional error data in tests. All review comments have been filtered out as they identified syntax errors that are caught by the analyzer, and therefore I have no feedback to provide.

@bkonyi bkonyi changed the title [CP-stable][flutter_tools] Handle target VM filesystem errors in DevFS.create [stable] [flutter_tools] Handle target VM filesystem errors in DevFS.create Nov 18, 2026

@justinmc justinmc 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.

LGTM 👍

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 18, 2026
@auto-submit
auto-submit Bot merged commit 2696cb9 into flutter:flutter-3.50-candidate.0 Nov 18, 2026
5 checks passed
@victorsanni victorsanni mentioned this pull request Nov 18, 2026
11 tasks done
auto-submit Bot pushed a commit that referenced this pull request Nov 19, 2026
Adds `CHANGELOG.md` entries for the 3.50.1 stable hotfix (#196756, #196721, #196127, #196035, #196418, #196800, #196796, #196895, #196383, #196923). Omits the infra-only #196760 and the `engine.version` sync #196932.

Tracker: #196743

### Edits to cherry-pick changelog descriptions
- All entries use the cherry-pick PR's "Changelog Description" verbatim, except for backticks around code terms (#196756, #196418, #196895, #196923) and a comma and trailing period in the #196418 entry.
- #196923 also cherry-picks #195006, so it has two entries, as listed in its "Changelog Description".

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants