Andrew Kolos 268cd08ffd
[CP-stable] Bump package:dds from version 4.2.4+1 to 4.2.4+2 (#155789)
CP Issue: https://github.com/flutter/flutter/issues/155837

Hopefully resolves the majority of the remaining `RPCError` crashes occurring on stable (context: https://github.com/flutter/flutter/issues/153471).

## Context and what is happening here
1. flutter_tools on the stable channel depends on package:dds@4.2.4+1
2. package:dds has a fix for these type of crashes, but was landed in [package:dds@4.2.6](212e49fda6)
3. I've created and published a 4.2.4+2 version of package:dds that patches the 4.2.6 fix into 4.2.4+1.
4. This PR makes flutter_tools depend on this new 4.2.4+2 version.

## Verifying this change

Unfortunately, I have not found a way to reproduce this particular crash (neither organically or inorganically through code modification). I am still decently confident this will fix any of the crashes (from https://github.com/flutter/flutter/issues/153471) that include `_withErrorHandling` in their stack trace.

However, we can at least be confident that this shouldn't _break_ anything new. The code change is very small.

The easiest way to check what code is being changed here is to `git diff` the version of package:dds we are bumping from and the one we are bumping to: `git diff /Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/ /Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2`. While I accidentally chose the incorrect base commit when creating 4.2.4+2, the dart code changes should still be minimal:

<details>

<summary>full diff (your IDE probably has a "diff" language mode to make this human-readable)</summary>

<pre>
diff --git a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/CHANGELOG.md b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/CHANGELOG.md
index a515f931cc..72cd187fbc 100644
--- a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/CHANGELOG.md
+++ b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 4.2.4+2
+- [DAP] Fixed an issue where "Service connection disposed" errors may go unhandled during termination/shutdown.Uint8List` from `dart:typed_data`.
+- Added `package:dds/dds_launcher.dart`, a library which can be used to launch DDS instances using `dart development-service`.
+
 # 4.2.4+1
 - Added missing type to `Event` in `postEvent`.
 - [DAP] Instaces with both fields and getters of the same name will no longer show duplicates in `variables` responses.
@@ -310,8 +314,8 @@ Hot-fix release of changes in 3.1.2 without the changes in 3.1.1
 # 1.7.0
 - Added `package:dds/vm_service_extensions.dart`, which adds DDS functionality to
   `package:vm_service` when imported.
-  - Added `onEventWithHistory` method and `onLoggingEventWithHistory`, 
-    `onStdoutEventWithHistory`, `onStderrEventWithHistory`, and 
+  - Added `onEventWithHistory` method and `onLoggingEventWithHistory`,
+    `onStdoutEventWithHistory`, `onStderrEventWithHistory`, and
     `onExtensionEventWithHistory` getters.
 - Added `getStreamHistory` RPC.
 
diff --git a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/CONTRIBUTING.md b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/CONTRIBUTING.md
index ddad214772..de7603b2f2 100644
--- a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/CONTRIBUTING.md
+++ b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/CONTRIBUTING.md
@@ -22,6 +22,14 @@ Then you can call `_fileLog('some print debugging message')`, and the log messag
 
 To get logging output in real time, run `tail -f /tmp/dds.log`.
 
+## Running DDS tests
+
+From the `$DART_SDK_ROOT` directory, run:
+
+```shell
+ dart --packages=.dart_tool/package_config.json pkg/dds/test/path/to/your_test.dart
+```
+
 ## Making changes to `package:dds` and `package:devtools_shared`
 
 **If you do not need to build the Dart SDK** to test your changes, you
@@ -38,7 +46,7 @@ dependency_overrides:
 to adding the dependency override above, you will need to add a symbolic link
 to your local `devtools_shared` directory:
 
-From the `sdk/` directory, run:
+From the `$DART_SDK_ROOT` directory, run:
 ```shell
 rm -rf third_party/devtools/devtools_shared;
 ln -s /absolute_path_to/devtools/packages/devtools_shared third_party/devtools/devtools_shared
@@ -51,3 +59,42 @@ To delete the symbolic link after you are done with development, run:
 ```shell
 rm -rf third_party/devtools/devtools_shared
 ```
+
+## Making changes to `package:dds` and `devtools_app`
+
+To test any changes made in `devtools_app`, you will need to first build DevTools.
+
+- If you have not already, make sure to [set-up your DevTools development environment](https://github.com/flutter/devtools/blob/master/CONTRIBUTING.md#set-up-your-devtools-environment) so that you can use the `devtools_tool` command.
+
+- Then build DevTools with `devtools_tool build`.
+
+In the SDK, add a symbolic link to your local `devtools/packages/devtools_app/build/web` directory.
+
+From the `$DART_SDK_ROOT` directory, run:
+
+```shell
+rm -rf third_party/devtools/web;
+ln -s /absolute_path_to/devtools/devtools/packages/devtools_app/build/web third_party/devtools/web
+```
+
+**WARNING**: do not run `gclient sync -D` while the symbolic link is present,
+as this could cause issues with your local `devtools_app` code.
+
+Then, build the Dart SDK.
+
+From the `$DART_SDK_ROOT` directory, run:
+
+```shell
+./tools/build.py -mrelease -ax64 create_sdk
+```
+
+To delete the symbolic link after you are done with development, run:
+
+**WARNING**: do not run `gclient sync -D` while the symbolic link is present,
+as this could cause issues with your local `devtools_app` code.
+
+```shell
+rm -rf third_party/devtools/web
+```
+
+Then, run `gclient sync` to pull down the checked in version of DevTools.
diff --git a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/lib/src/dap/adapters/dart.dart b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/lib/src/dap/adapters/dart.dart
index 51228f24be..1a0a1f6287 100644
--- a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/lib/src/dap/adapters/dart.dart
+++ b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/lib/src/dap/adapters/dart.dart
@@ -2845,7 +2845,8 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
         // errors because these can always occur during shutdown if we were
         // just starting to send (or had just sent) a request.
         if (e.message.contains("The client is closed") ||
-            e.message.contains("The client closed with pending request")) {
+            e.message.contains("The client closed with pending request") ||
+            e.message.contains("Service connection disposed")) {
           return null;
         }
       }
diff --git a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/lib/src/dds_cli_entrypoint.dart b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/lib/src/dds_cli_entrypoint.dart
index 1680cba55c..8546707a5e 100644
--- a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/lib/src/dds_cli_entrypoint.dart
+++ b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/lib/src/dds_cli_entrypoint.dart
@@ -129,7 +129,6 @@ ${argParser.usage}
           'uri': dtdInfo.uri,
         },
     }));
-    stderr.close();
   } catch (e, st) {
     writeErrorResponse(e, st);
   } finally {
diff --git a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/pubspec.yaml b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/pubspec.yaml
index c159257a1a..e136322d54 100644
--- a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/pubspec.yaml
+++ b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/pubspec.yaml
@@ -1,5 +1,5 @@
 name: dds
-version: 4.2.4+1
+version: 4.2.4+2
 description: >-
   A library used to spawn the Dart Developer Service, used to communicate with
   a Dart VM Service instance.

</pre>

</details>

You might have notice this extraneous change in particular:

```diff
diff --git a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/lib/src/dds_cli_entrypoint.dart b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/lib/src/dds_cli_entrypoint.dart
index 1680cba55c..8546707a5e 100644
--- a/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+1/lib/src/dds_cli_entrypoint.dart
+++ b/Users/andrewkolos/.pub-cache/hosted/pub.dev/dds-4.2.4+2/lib/src/dds_cli_entrypoint.dart
@@ -129,7 +129,6 @@ ${argParser.usage}
           'uri': dtdInfo.uri,
         },
     }));
-    stderr.close();
   } catch (e, st) {
     writeErrorResponse(e, st);
   } finally {
```

This is is from 56416078a0. As you can see, there is already a `stderr.close` call in the finally block, so this change is just a refactor and safe to be in this cherry-pick.
2024-10-01 12:57:21 +00:00
..
…
2024-06-17 17:26:08 +00:00

Flutter Tools

This section of the Flutter repository contains the command line developer tools for building Flutter applications.

Working on Flutter Tools

Be sure to follow the instructions on CONTRIBUTING.md to set up your development environment. Further, familiarize yourself with the style guide, which we follow.

Setting up

First, ensure that the Dart SDK and other necessary artifacts are available by invoking the Flutter Tools wrapper script. In this directory run:

$ flutter --version

Running the Tool

To run Flutter Tools from source, in this directory run:

$ dart bin/flutter_tools.dart

followed by command-line arguments, as usual.

Running the analyzer

To run the analyzer on Flutter Tools, in this directory run:

$ flutter analyze

Writing tests

As with other parts of the Flutter repository, all changes in behavior must be tested. Tests live under the test/ subdirectory.

  • Hermetic unit tests of tool internals go under test/general.shard and must run in significantly less than two seconds.

  • Tests of tool commands go under test/commands.shard. Hermetic tests go under its hermetic/ subdirectory. Non-hermetic tests go under its permeable sub-directory. Avoid adding tests here and prefer writing either a unit test or a full integration test.

  • Integration tests (e.g. tests that run the tool in a subprocess) go under test/integration.shard.

  • Slow web-related tests go in the test/web.shard directory.

In general, the tests for the code in a file called file.dart should go in a file called file_test.dart in the subdirectory that matches the behavior of the test.

The dart_test.yaml file configures the timeout for these tests to be 15 minutes. The test.dart script that is used in CI overrides this to two seconds for the test/general.shard directory, to catch behaviour that is unexpectedly slow.

Please avoid setting any other timeouts.

Using local engine builds in integration tests

The integration tests can be configured to use a specific local engine variant by setting the FLUTTER_LOCAL_ENGINE and FLUTTER_LOCAL_ENGINE_HOST environment svariable to the name of the local engines (e.g. android_debug_unopt and host_debug_unopt). If the local engine build requires a source path, this can be provided by setting the FLUTTER_LOCAL_ENGINE_SRC_PATH environment variable. This second variable is not necessary if the flutter and engine checkouts are in adjacent directories.

export FLUTTER_LOCAL_ENGINE=android_debug_unopt
export FLUTTER_LOCAL_ENGINE_HOST=host_debug_unopt
flutter test test/integration.shard/some_test_case

Running the tests

To run all of the unit tests:

$ flutter test test/general.shard

The tests in test/integration.shard are slower to run than the tests in test/general.shard. Depending on your development computer, you might want to limit concurrency. Generally it is easier to run these on CI, or to manually verify the behavior you are changing instead of running the test.

The integration tests also require the FLUTTER_ROOT environment variable to be set. The full invocation to run everything might therefore look something like:

$ export FLUTTER_ROOT=~/path/to/flutter-sdk
$ flutter test --concurrency 1

This may take some time (on the order of an hour). The unit tests alone take much less time (on the order of a minute).

You can run the tests in a specific file, e.g.:

$ flutter test test/general.shard/utils_test.dart

Forcing snapshot regeneration

To force the Flutter Tools snapshot to be regenerated, delete the following files:

$ rm ../../bin/cache/flutter_tools.stamp ../../bin/cache/flutter_tools.snapshot