Skip to content

Commit 0be4122

Browse files
committed
fix: increase gsoc websocket buffer to absorb legitimate bursts
dataC's buffer of 2 was too small for a legitimate burst of GSOC messages delivered concurrently to the same subscriber (e.g. several chunks pushed at once), causing a false-positive slow-consumer disconnect. Bump it to 16 and adjust the slow-consumer test's message count so overflow is still hit deterministically.
1 parent b15df1b commit 0be4122

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

pkg/api/gsoc.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ func (s *Service) gsocListeningWs(conn *websocket.Conn, socAddress swarm.Address
171171
defer s.wsWg.Done()
172172

173173
var (
174-
dataC = make(chan []byte, 2) // small buffer to decouple producer/consumer
174+
// Buffered enough to absorb a legitimate burst of concurrently delivered
175+
// GSOC messages (e.g. several chunks pushed to this address at once)
176+
// without tripping the slow-consumer detection below.
177+
dataC = make(chan []byte, 16)
175178
gone = make(chan struct{})
176179
slow = make(chan struct{})
177180
slowOnce sync.Once

pkg/api/gsoc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func TestGsocWebsocketInvalidFieldsHeader(t *testing.T) {
290290
func TestGsocWebsocketSlowConsumer(t *testing.T) {
291291
t.Parallel()
292292

293-
const messageCount = 10
293+
const messageCount = 32 // exceeds dataC's buffer so the overflow is hit deterministically
294294

295295
var (
296296
id = make([]byte, 32)

0 commit comments

Comments
 (0)