From 02a67cbd2acb82b92d1781eb161bcde4e71f02e4 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Thu, 10 Apr 2025 08:29:19 -0700 Subject: [PATCH] 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. --- internal/grid/connection.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/grid/connection.go b/internal/grid/connection.go index b79d6efa9..981573365 100644 --- a/internal/grid/connection.go +++ b/internal/grid/connection.go @@ -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 {