Commit 7f50a90
fix: synchronize ClientTaskManager to prevent race condition in concu… (#742)
…rrent SSE event processing
ClientTaskManager was not thread-safe, causing intermittent test
failures when
SSE events were delivered concurrently by the HTTP client. The race
condition
occurred when multiple events (startWork, addArtifact, complete) were
emitted
rapidly in streaming mode.
Without synchronization, concurrent threads could interleave
read-modify-write
operations on currentTask, resulting in lost updates. Specifically, the
artifact
update could be overwritten by a status update, leaving the final
COMPLETED task
with no artifacts. The fast time to failure of the test 0.017s,
indicates that the
COMPLETED status update was received, and that the latch did not time
out.
This manifested as intermittent failures in agent-to-agent tests where
the test
received a COMPLETED task but extractTextFromTask() returned an empty
string
because the artifact list was empty.
Fix: Added synchronized keyword to all ClientTaskManager methods
(getCurrentTask,
saveTaskEvent variants, updateWithMessage) to ensure atomic processing
of events
regardless of HTTP client threading behavior.
Impact: All client transports (JSON-RPC, gRPC, REST) in streaming mode
Validated: 100 consecutive test iterations passed on CI
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent ab77fd0 commit 7f50a90
1 file changed
Lines changed: 5 additions & 5 deletions
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
0 commit comments