Drained
A close of this seam or connection that follows goes out behind every send accepted before flush was called, so it cannot be what throws those frames away on this device. That is the whole promise, and three things stay outside it:
The frames may not have left this process. They can still be in the transport library's own queue: a WebSocket frame can sit in Ktor's. So close the seam itself. Closing the
HttpClient, cancelling the session or exiting straight after can still lose them (read from Ktor's source, not run).The link can still die on the way, and the far side can still crash before reading.
A far side that is still sending can lose them after they arrive. Its own send fails on the link your close ended, that tears its seam, and a torn seam stops reading what it had not got to. Measured with a slow consumer sending 1 frame per 100 ms: lost frames in 32 of 32 WebSocket trials, and 0 of 24 with nothing coming back. TCP lost them 6 of 6. That is macOS loopback, and how often it happens depends on the machine: a Linux CI runner's TCP trials lost nothing, 3 of 3.