Files
goclaw/cmd
yatulandClaude Opus 5 34cc6e011d test(teams): fix the data races in the teammate streaming test (#1556)
TestHandleTeammateMessageSchedulesStreamedRun fails CI intermittently under
-race. Two separate races, both in the test rather than in what it exercises:

  1. It shared `gotReq` between the scheduler's RunFunc and the assertions. The
     RunFunc runs on a scheduler goroutine, and the announce loop schedules a
     second run after the teammate one, so the write could land while the test
     was reading — and the second run also closed an already-closed channel.
     Requests now arrive over a buffered channel: no shared state, and a second
     run cannot clobber the first.

  2. The deferred sched.Stop() ran while handleTeammateMessage's background
     goroutine was still calling Schedule, so Lane.Submit's wg.Add raced
     Lane.Stop's wg.Wait. The gateway drains BgWg before stopping the scheduler
     (gateway_consumer.go waits on it; sched.Stop is an outer defer in
     gateway.go); the test skipped that step. It now drains too, which also makes
     the test match the shutdown order it is meant to represent.

Reproduced before the fix with `-race -count=60 -cpu=1,4` (fails within a few
iterations) and clean afterwards over `-count=200 -cpu=1,2,4`, plus the whole
cmd package under -race.

Nothing in production changes; `Stream: true` and the channel-manager assertion
are untouched.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-09 09:01:31 +07:00
..
2026-07-15 09:56:43 +07:00
2026-06-12 09:48:01 +07:00