mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Shut down DevTools and DDS processes if flutter_tools is killed by a signal (#159238)
See https://github.com/flutter/flutter/issues/159154
This commit is contained in:
parent
c7dd6419d9
commit
efe8737ea0
@ -69,7 +69,6 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
|
||||
final ResidentRunner _residentRunner;
|
||||
final Logger _logger;
|
||||
bool _shutdown = false;
|
||||
bool _served = false;
|
||||
|
||||
@visibleForTesting
|
||||
bool launchedInBrowser = false;
|
||||
@ -105,7 +104,6 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
|
||||
_devToolsLauncher.devToolsUrl = devToolsServerAddress;
|
||||
} else {
|
||||
await _devToolsLauncher.serve();
|
||||
_served = true;
|
||||
}
|
||||
await _devToolsLauncher.ready;
|
||||
// Do not attempt to print debugger list if the connection has failed or if we're shutting down.
|
||||
@ -305,7 +303,7 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
|
||||
@override
|
||||
Future<void> shutdown() async {
|
||||
_shutdown = true;
|
||||
if (_devToolsLauncher == null || !_served) {
|
||||
if (_devToolsLauncher == null) {
|
||||
return;
|
||||
}
|
||||
_readyToAnnounce = false;
|
||||
|
@ -1248,8 +1248,10 @@ class HotRunner extends ResidentRunner {
|
||||
|
||||
@override
|
||||
Future<void> cleanupAfterSignal() async {
|
||||
await residentDevtoolsHandler!.shutdown();
|
||||
await stopEchoingDeviceLog();
|
||||
await hotRunnerConfig!.runPreShutdownOperations();
|
||||
shutdownDartDevelopmentService();
|
||||
if (stopAppDuringCleanup) {
|
||||
return exitApp();
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class FakeDevice extends Fake implements Device {
|
||||
bool disposed = false;
|
||||
|
||||
@override
|
||||
final DartDevelopmentService dds = _FakeDartDevelopmentService();
|
||||
final DartDevelopmentService dds = FakeDartDevelopmentService();
|
||||
|
||||
@override
|
||||
bool isSupported() => true;
|
||||
@ -94,9 +94,13 @@ class FakeDevice extends Fake implements Device {
|
||||
}
|
||||
}
|
||||
|
||||
class _FakeDartDevelopmentService extends Fake implements DartDevelopmentService {
|
||||
class FakeDartDevelopmentService extends Fake implements DartDevelopmentService {
|
||||
bool wasShutdown = false;
|
||||
|
||||
@override
|
||||
void shutdown() {}
|
||||
void shutdown() {
|
||||
wasShutdown = true;
|
||||
}
|
||||
}
|
||||
|
||||
class FakeFlutterDevice extends Fake implements FlutterDevice {
|
||||
|
@ -9,6 +9,7 @@ import 'package:flutter_tools/src/compile.dart';
|
||||
import 'package:flutter_tools/src/devfs.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/resident_devtools_handler.dart';
|
||||
import 'package:flutter_tools/src/resident_runner.dart';
|
||||
import 'package:flutter_tools/src/run_hot.dart';
|
||||
import 'package:flutter_tools/src/vmservice.dart';
|
||||
@ -56,11 +57,14 @@ void main() {
|
||||
target: 'main.dart',
|
||||
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug),
|
||||
analytics: _FakeAnalytics(),
|
||||
devtoolsHandler: createNoOpHandler,
|
||||
);
|
||||
|
||||
await runner.run();
|
||||
await runner.cleanupAfterSignal();
|
||||
expect(flutterDevice.wasExited, true);
|
||||
expect((flutterDevice.device.dds as FakeDartDevelopmentService).wasShutdown, true);
|
||||
expect((runner.residentDevtoolsHandler! as NoOpDevtoolsHandler).wasShutdown, true);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
|
Loading…
Reference in New Issue
Block a user