Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

fix(aslog): implement TryLock to prevent deadlock in workerMsgUpdater

Dmitry Ng75eb8e0f1ecb
diff --git a/backend/pkg/controller/aslog.go b/backend/pkg/controller/aslog.go
index a7b3f68e..9074cccc 100644
--- a/backend/pkg/controller/aslog.go
+++ b/backend/pkg/controller/aslog.go
@@ -373,7 +373,14 @@ func (aslw *flowAssistantLogWorker) workerMsgUpdater(
for {
select {
case <-timer.C:
- aslw.mx.Lock()
+ // TryLock avoids a deadlock: while this branch holds up reading from ch,
+ // StreamFlowAssistantMsg may be blocked on a full ch <- chunk while
+ // holding aslw.mx. If the mutex is taken, the stream is still active —
+ // reset the timer and keep draining instead of blocking.
+ if !aslw.mx.TryLock() {
+ timer.Reset(updateMsgTimeout)
+ continue
+ }
defer aslw.mx.Unlock()
for i := 0; i < len(ch); i++ {