File tree 2 files changed +18
-0
lines changed 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,10 @@ class DaemonStreams {
219
219
if (binary != null ) {
220
220
_outputSink.add (binary);
221
221
}
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 ();
222
226
} on IOException catch (error) {
223
227
_logger.printError ('Failed to write daemon command response: $error ' );
224
228
// Failed to send, close the connection
Original file line number Diff line number Diff line change @@ -364,6 +364,20 @@ void main() {
364
364
await daemonStreams.dispose ();
365
365
expect (outputStream.isClosed, true );
366
366
});
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
+ });
367
381
});
368
382
}
369
383
You can’t perform that action at this time.
0 commit comments