outboxDrained property
Future<void>
get
outboxDrained
Completes once every queued outbound byte has been flushed to the wire (or immediately if nothing is queued). A clean close should await this before calling close, which clears the outbox — otherwise credit-gated output still waiting for the peer's window would be silently discarded (truncating large command output on exit).
Implementation
Future<void> get outboxDrained {
if (_outbox.isEmpty || _closed) return Future<void>.value();
final completer = Completer<void>();
_drainWaiters.add(completer);
return completer.future;
}