diff --git a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart index 9f966438e6..990b1da500 100644 --- a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart @@ -249,6 +249,10 @@ class ResidentWebRunner extends ResidentRunner { 'This can happen if the websocket connection used by the web tooling is ' 'unabled to correctly establish a connection, for example due to a firewall.' ); + } on MissingPortFile { + throwToolExit( + 'Failed to connect to build daemon.\nThe daemon either failed to ' + 'start or was killed by another process.'); } on SocketException catch (err) { throwToolExit(err.toString()); } finally { diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart index 188dddf599..3ba6b311ce 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart @@ -677,6 +677,25 @@ void main() { await expectation; })); + test('Successfully turns MissingPortFile error into ToolExit', () => testbed.run(() async { + _setupMocks(); + final Completer connectionInfoCompleter = Completer(); + final Completer unhandledErrorCompleter = Completer(); + when(mockWebFs.connect(any)).thenAnswer((Invocation _) async { + unawaited(unhandledErrorCompleter.future.then((void value) { + throw MissingPortFile(); + })); + return ConnectionResult(mockAppConnection, mockDebugConnection); + }); + + final Future expectation = expectLater(() => residentWebRunner.run( + connectionInfoCompleter: connectionInfoCompleter, + ), throwsA(isInstanceOf())); + + unhandledErrorCompleter.complete(); + await expectation; + })); + test('Rethrows unknown exception type from web tooling', () => testbed.run(() async { _setupMocks(); final DelegateLogger delegateLogger = logger;