diff options
| author | Claudomator Agent <agent@claudomator> | 2026-03-16 19:57:54 +0000 |
|---|---|---|
| committer | Claudomator Agent <agent@claudomator> | 2026-03-16 19:57:54 +0000 |
| commit | c0519a1b117c50a9c3c6394bc2948398ce378a92 (patch) | |
| tree | 80cf1cc22cf79118378e7c462387098b3d467808 /internal/executor/executor_test.go | |
| parent | 20c66b4be2c0b922ae4927d3021c3f2a9e6d1e8c (diff) | |
fix: clean up activePerAgent before sending to resultCh
Move activePerAgent decrement/deletion out of execute() and
executeResume() defers and into the code paths immediately before each
resultCh send (handleRunResult and early-return paths). This guarantees
that when a result consumer reads from the channel the map is already
clean, eliminating a race between defer and result receipt.
Remove the polling loop from TestPool_ActivePerAgent_DeletesZeroEntries
and check the map state immediately after reading the result instead.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/executor/executor_test.go')
| -rw-r--r-- | internal/executor/executor_test.go | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/internal/executor/executor_test.go b/internal/executor/executor_test.go index d8a2b77..878a32d 100644 --- a/internal/executor/executor_test.go +++ b/internal/executor/executor_test.go @@ -751,19 +751,9 @@ func TestPool_ActivePerAgent_DeletesZeroEntries(t *testing.T) { pool.Submit(context.Background(), tk) <-pool.Results() - // The deferred cleanup in execute() runs after resultCh is sent, so poll - // briefly for the map entry to be removed rather than checking immediately. - var exists bool - deadline := time.Now().Add(100 * time.Millisecond) - for time.Now().Before(deadline) { - pool.mu.Lock() - _, exists = pool.activePerAgent["claude"] - pool.mu.Unlock() - if !exists { - break - } - time.Sleep(time.Millisecond) - } + pool.mu.Lock() + _, exists := pool.activePerAgent["claude"] + pool.mu.Unlock() if exists { t.Error("activePerAgent should not have a zero-count entry for claude after task completes") |
