Repository navigation
[flutter_tools] Handle target VM filesystem errors in DevFS.create - #196234
Merged
Merged
Conversation
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._createDevFSOnDevice` (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)
#1 _Directory.createTemp.<anonymous closure> (dart:io/directory_impl.dart:163:7)
<asynchronous suspension>
#2 createTempDirCallback (dart:vmservice_io:101:16)
<asynchronous suspension>
#3 DevFS._createDevFS (dart:_vmservice/devfs.dart:197:21)
<asynchronous suspension>
#4 VMService._routeRequestImpl (dart:_vmservice:759:16)
<asynchronous suspension>
#5 VMService.routeRequest (dart:_vmservice:726:22)
<asynchronous suspension>
#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)
#1 VmService._call.<anonymous closure> (package:vm_service/src/vm_service.dart:1962:25)
#2 VmService._call (package:vm_service/src/vm_service.dart:1974:8)
#3 VmService.callServiceExtension (package:vm_service/src/vm_service.dart:1913:14)
#4 FlutterVmService.createDevFS (package:flutter_tools/src/vmservice.dart:1060:20)
#5 DevFS.create (package:flutter_tools/src/devfs.dart:497:61)
#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
8 of 11 tasks
bkonyi
marked this pull request as ready for review
November 12, 2026 02:44
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors DevFS creation to extract and include target VM file system error details when throwing a DevFSException, and adds corresponding unit and integration tests. The review feedback points out that the ?error syntax used in DevFSException.toString() is non-standard Dart and suggests using Dart 3 pattern matching instead. Additionally, it is recommended to make the stack trace extraction in _extractTargetFileSystemError more robust against Windows line endings.
Addresses review feedback on flutter#196234 by defining `_stackTraceStartPattern = RegExp(r'\r?\n#0')` in `DevFS._extractTargetFileSystemError` and updating the Windows `PathAccessException` unit test in `devfs_test.dart` to cover `\r\n#0` stack trace delimiters. 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)) ```
Inline the existing-filesystem retry loop and target VM filesystem `RPCError` translation directly in `DevFS.create`, removing `_createDevFSOnDevice`, `_extractTargetFileSystemError`, and redundant regex helpers. Add optional `data` support to `FakeRPCError` in `test/src/fake_vm_services.dart`, replace the custom `_RpcErrorWithDetailsHost` harness in `devfs_test.dart` with `FakeVmServiceHost`, and drop the redundant multi-process `flutter_attach_test.dart` integration test.
Replace the conditionless `for` loop in `DevFS.create` with an idiomatic `do-while` loop keyed on `baseUri == null`, removing both `break` and the `_baseUri!` null assertion.
Drop `dotAll: true` from `DevFS._targetFileSystemErrorPattern` so `.*`
stops at the newline before the target VM stack trace, removing the
manual `details.split('\n#0')` and `error.replaceAll` steps. Document
both the `_createDevFS` `kInternalError` wire format and the static
`DevFSException.message` crash-sanitization contract.
chingjun
approved these changes
Nov 17, 2026
Contributor
|
autosubmit label was removed for flutter/flutter/196234, because - The status or check suite Presubmit has failed. Please fix the issues identified (or deflake) before re-applying this label. |
2 of 5 tasks
This was referenced Nov 18, 2026
LouiseHsu
pushed a commit
to flutter/packages
that referenced
this pull request
Nov 18, 2026
flutter/flutter@2f09f96...06f32f8 2026-11-18 [email protected] Move macOS desktop builds to ThinLTO (flutter/flutter#196804) 2026-11-18 [email protected] Roll Dart SDK from 5ed55b4b2ebc to 753488ede427 (2 revisions) (flutter/flutter#196893) 2026-11-18 [email protected] Roll Packages from 9af69be to dca2e58 (7 revisions) (flutter/flutter#196892) 2026-11-18 [email protected] Roll Skia from 503a380ebecc to 81ee7327e81c (29 revisions) (flutter/flutter#196889) 2026-11-18 [email protected] Roll Dart SDK from 26e38955d9d4 to 5ed55b4b2ebc (4 revisions) (flutter/flutter#196843) 2026-11-18 [email protected] Fix permissions for action updates (flutter/flutter#196791) 2026-11-18 [email protected] iOS: Apply platform view mutators from FlutterPlatformViewLayer (flutter/flutter#196753) 2026-11-18 [email protected] [flutter_tools] Remove ambient Doctor, FeatureFlags, and device getters (flutter/flutter#196572) 2026-11-18 [email protected] Fix RelativeRect.lerp crash when b is null (flutter/flutter#196655) 2026-11-18 [email protected] [web] Harden WebP and GIF header readers against truncated and malformed buffers (flutter/flutter#196075) 2026-11-17 [email protected] Enable apps to control focus behavior during app lifecycle changes via `FocusLifecyclePolicy` (flutter/flutter#190570) 2026-11-17 [email protected] Don't re-run the code freeze check on label changes (flutter/flutter#196745) 2026-11-17 [email protected] Android: Report FlutterView as a text editor while a text input client is attached (flutter/flutter#193074) 2026-11-17 [email protected] Roll Packages from 4c6a7d3 to 9af69be (5 revisions) (flutter/flutter#196812) 2026-11-17 [email protected] [flutter_tools] Handle target VM filesystem errors in DevFS.create (flutter/flutter#196234) 2026-11-17 [email protected] [flutter_tools] Clarify analytics reporting status when on a feature branch (flutter/flutter#194496) 2026-11-17 [email protected] [web] Recover CanvasKit surfaces from WebGL failures without per-frame null crashes (flutter/flutter#196257) 2026-11-17 [email protected] [devicelab] Trigger navigation tap via Flutter Driver in service_extensions_test (flutter/flutter#194456) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit Bot
pushed a commit
that referenced
this pull request
Nov 18, 2026
…create (#196895) Cherry-pick of #196234. 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: #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? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### 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.
jose-pr
pushed a commit
to Boriken-Dev/flutter
that referenced
this pull request
Nov 23, 2026
…create (#196895) Cherry-pick of flutter/flutter#196234. 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: flutter/flutter#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? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously,
DevFS.createonly translated VM service disconnection RPC errors (kServiceDisappeared,kConnectionDisposed) and retried1001(kFileSystemAlreadyExists), rethrowing all otherRPCErrorinstances 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 fullTMP/TEMP/TMPDIRdirectory on the target machine or device), the VM service returnedRPCError-32603(kInternalError) wrapping adart:ioFileSystemException(PathAccessException,PathNotFoundException,PathExistsException, orFileSystemException). That unhandledRPCErrorescapedHotRunner._attach/HotRunner.runand triggered crash reporting.Translate
-32603RPCErrorresponses whosedetailswrap a target VMFileSystemExceptionintoDevFSException('Failed to create DevFS on device', fileSystemError)inDevFS.create(including on the retry attempt afterdestroy()), keepingDevFSException.messagePII-free forGitHubTemplateCreator.sanitizedCrashExceptionwhile surfacing the underlying OS filesystem error inDevFSException.errorandDevFSException.toString(). Non-filesystem-32603internal VM errors continue to rethrow to crash reporting. Also typeDevFSException.errorasObject?and omitnulloptional fields inDevFSException.toString().Reproduced against
flutter_testerlaunched with a read-onlyTMPDIR=/tmp/flutter_devfs_repro_readonly(chmod 0555) andBOT=trueonflutter attach:Previous output:
Current output:
Fixes #196118