From 6ce8dc53e79842af71f0b4a360cb65d9eaa1e8f7 Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Mon, 7 Sep 2026 22:14:41 +0100 Subject: [PATCH] common/buf/writer.go: Fix buffered writes failing when payload exceeds remaining capacity (#6723) Fixes https://github.com/XTLS/Xray-core/issues/5287 --- common/buf/writer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/buf/writer.go b/common/buf/writer.go index 6ff8a6b6b..f14d83c3d 100644 --- a/common/buf/writer.go +++ b/common/buf/writer.go @@ -118,7 +118,9 @@ func (w *BufferedWriter) Write(b []byte) (int, error) { nBytes, err := w.buffer.Write(b) totalBytes += nBytes - if err != nil { + + // ErrBufferFull means a partial write, so flush below and continue + if err != nil && err != ErrBufferFull { return totalBytes, err } if !w.buffered || w.buffer.IsFull() {