Stop the DevTools child process if the runner terminates unexpectedly (#80602)
This commit is contained in:
@@ -208,6 +208,8 @@ NoOpDevtoolsHandler createNoOpHandler(DevtoolsLauncher launcher, ResidentRunner
|
||||
|
||||
@visibleForTesting
|
||||
class NoOpDevtoolsHandler implements ResidentDevtoolsHandler {
|
||||
bool wasShutdown = false;
|
||||
|
||||
@override
|
||||
DevToolsServerAddress get activeDevToolsServer => null;
|
||||
|
||||
@@ -223,6 +225,7 @@ class NoOpDevtoolsHandler implements ResidentDevtoolsHandler {
|
||||
|
||||
@override
|
||||
Future<void> shutdown() async {
|
||||
wasShutdown = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +204,7 @@ class ColdRunner extends ResidentRunner {
|
||||
await flutterDevice.device.dispose();
|
||||
}
|
||||
|
||||
await residentDevtoolsHandler.shutdown();
|
||||
await stopEchoingDeviceLog();
|
||||
}
|
||||
|
||||
|
||||
@@ -1163,6 +1163,7 @@ class HotRunner extends ResidentRunner {
|
||||
await flutterDevice.device.dispose();
|
||||
}
|
||||
await _cleanupDevFS();
|
||||
await residentDevtoolsHandler.shutdown();
|
||||
await stopEchoingDeviceLog();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2452,6 +2452,21 @@ void main() {
|
||||
expect(nextPlatform('macOS'), 'android');
|
||||
expect(() => nextPlatform('unknown'), throwsAssertionError);
|
||||
});
|
||||
|
||||
testUsingContext('cleanupAtFinish shuts down resident devtools handler', () => testbed.run(() async {
|
||||
residentRunner = HotRunner(
|
||||
<FlutterDevice>[
|
||||
mockFlutterDevice,
|
||||
],
|
||||
stayResident: false,
|
||||
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, vmserviceOutFile: 'foo'),
|
||||
target: 'main.dart',
|
||||
devtoolsHandler: createNoOpHandler,
|
||||
);
|
||||
await residentRunner.cleanupAtFinish();
|
||||
|
||||
expect((residentRunner.residentDevtoolsHandler as NoOpDevtoolsHandler).wasShutdown, true);
|
||||
}));
|
||||
}
|
||||
|
||||
class MockFlutterDevice extends Mock implements FlutterDevice {}
|
||||
|
||||
Reference in New Issue
Block a user