Fix buffered streams missing final entries (#21122)

On buffered streams the final entries could be missing, if a lot 
are delivered when stream ends.

Fixes end-of-stream cancelling return of final entries by canceling
with the StreamEOF error.
This commit is contained in:
Klaus Post 2025-04-10 08:29:19 -07:00 committed by GitHub
parent 2b34e5b9ae
commit 02a67cbd2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1634,10 +1634,9 @@ func (c *Connection) handleMuxServerMsg(ctx context.Context, m message) {
}
if m.Flags&FlagEOF != 0 {
if v.cancelFn != nil && m.Flags&FlagPayloadIsErr == 0 {
// We must obtain the lock before calling cancelFn
// We must obtain the lock before closing
// Otherwise others may pick up the error before close is called.
v.respMu.Lock()
v.cancelFn(errStreamEOF)
v.closeLocked()
v.respMu.Unlock()
} else {