[flutter_tools] [dap] Ensure DAP sends app.stop/app.detach during terminate (#108310)

* [flutter_tools] [dap] Ensure DAP sends app.stop/app.detach during terminate

Fixes an issue where the flutter_tester device may not be cleaned up correctly if we just terminate the Flutter process.

* Update integration test expectations

* Revert accidental commit
This commit is contained in:
Danny Tuppeny
2022-07-26 10:48:38 +01:00
committed by GitHub
parent 925bee92e7
commit 5d31b07ed5
4 changed files with 69 additions and 0 deletions

View File

@@ -400,6 +400,16 @@ class FlutterDebugAdapter extends DartDebugAdapter<FlutterLaunchRequestArguments
if (isAttach) {
await preventBreakingAndResume();
}
// Send a request to stop/detach to give Flutter chance to do some cleanup.
// It's possible the Flutter process will terminate before we process the
// response, so accept either a response or the process exiting.
final String method = isAttach ? 'app.detach' : 'app.stop';
await Future.any<void>(<Future<void>>[
sendFlutterRequest(method, <String, Object?>{'appId': _appId}),
_process?.exitCode ?? Future<void>.value(),
]);
terminatePids(ProcessSignal.sigterm);
await _process?.exitCode;
}