File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,10 @@ class DaemonStreams {
219219 if (binary != null ) {
220220 _outputSink.add (binary);
221221 }
222+ } on StateError catch (error) {
223+ _logger.printError ('Failed to write daemon command response: $error ' );
224+ // Failed to send, close the connection
225+ _outputSink.close ();
222226 } on IOException catch (error) {
223227 _logger.printError ('Failed to write daemon command response: $error ' );
224228 // Failed to send, close the connection
Original file line number Diff line number Diff line change @@ -364,6 +364,20 @@ void main() {
364364 await daemonStreams.dispose ();
365365 expect (outputStream.isClosed, true );
366366 });
367+
368+ testWithoutContext ('handles sending to a closed sink' , () async {
369+ // Unless the stream is listened to, the call to .close() will never
370+ // complete
371+ outputStream.stream.listen ((List <int > _) {});
372+ await outputStream.sink.close ();
373+ daemonStreams.send (testCommand);
374+ expect (
375+ bufferLogger.errorText,
376+ contains (
377+ 'Failed to write daemon command response: Bad state: Cannot add event after closing' ,
378+ ),
379+ );
380+ });
367381 });
368382}
369383
You can’t perform that action at this time.
0 commit comments