Unverified Commit ac791adb authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] flutter daemon handles a closed stdout IOSink (#105075)

parent feda45a5
......@@ -219,6 +219,10 @@ class DaemonStreams {
if (binary != null) {
_outputSink.add(binary);
}
} on StateError catch (error) {
_logger.printError('Failed to write daemon command response: $error');
// Failed to send, close the connection
_outputSink.close();
} on IOException catch (error) {
_logger.printError('Failed to write daemon command response: $error');
// Failed to send, close the connection
......
......@@ -364,6 +364,20 @@ void main() {
await daemonStreams.dispose();
expect(outputStream.isClosed, true);
});
testWithoutContext('handles sending to a closed sink', () async {
// Unless the stream is listened to, the call to .close() will never
// complete
outputStream.stream.listen((List<int> _) {});
await outputStream.sink.close();
daemonStreams.send(testCommand);
expect(
bufferLogger.errorText,
contains(
'Failed to write daemon command response: Bad state: Cannot add event after closing',
),
);
});
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment