diff --git a/send_stream.go b/send_stream.go index bbc5140e..1a09eec9 100644 --- a/send_stream.go +++ b/send_stream.go @@ -398,7 +398,7 @@ func (s *sendStream) isNewlyCompleted() bool { func (s *sendStream) Close() error { s.mutex.Lock() - if s.closeForShutdownErr != nil { + if s.closeForShutdownErr != nil || s.finishedWriting { s.mutex.Unlock() return nil } diff --git a/send_stream_test.go b/send_stream_test.go index 7859820a..a5638c07 100644 --- a/send_stream_test.go +++ b/send_stream_test.go @@ -431,8 +431,6 @@ func TestSendStreamClose(t *testing.T) { require.False(t, hasMore) // further calls to Close don't do anything - // TODO(#4800): there shouldn't be any calls to mockSender - mockSender.EXPECT().onHasStreamData(streamID, str) require.NoError(t, str.Close()) _, ok, hasMore = str.popStreamFrame(protocol.MaxByteCount, protocol.Version1) require.False(t, ok)