Commit a9d803e
committed
fix: Wait for cleanup completion in blocking path to prevent agent map leak
Root cause: In onMessageSend() blocking requests, cleanupProducer() returned
a CompletableFuture but we didn't wait for it. The whenComplete callback
(which removes agents from runningAgents map) was racing and sometimes not
executing before returning to client.
Evidence from CI logs:
- 193 agents registered
- 172 agents removed
- 21 agents leaked (stayed in map with status DONE)
- Active threads grew from 28 → 47
- Progressive slowdown on CI (2-4 vCPU constraint)
Fix: Add .join() to wait for cleanup completion in blocking path. This
ensures the whenComplete callback executes and the agent is removed from
the runningAgents map before returning to client.
For non-blocking/streaming paths, cleanup continues in background as before.1 parent 5e9eab6 commit a9d803e
File tree
1 file changed
+2
-1
lines changed- server-common/src/main/java/io/a2a/server/requesthandlers
1 file changed
+2
-1
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
| 224 | + | |
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
| |||
0 commit comments