Skip to content

Commit

Permalink
WebSocket: Ensure full writes to compressor
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
neilalexander committed Nov 8, 2024
1 parent 73a481d commit e331a26
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,12 @@ func (c *client) wsCollapsePtoNB() (net.Buffers, int64) {
}
var csz int
for _, b := range nb {
cp.Write(b)
wb := bytes.NewBuffer(b)
if _, err := io.Copy(cp, wb); err != nil {
c.Errorf("Error during compression: %v", err)
c.markConnAsClosed(WriteError)
return nil, 0
}
nbPoolPut(b) // No longer needed as contents written to compressor.
}
if err := cp.Flush(); err != nil {
Expand Down

0 comments on commit e331a26

Please sign in to comment.