mirror of
https://github.com/humanlayer/humanlayer.git
synced 2025-08-20 19:01:22 +03:00
fix: prevent transient failed status when interrupting sessions
When a session is interrupted, there's a race condition where the monitor goroutine sees the process exit with an error and briefly marks the session as failed before it transitions to completed. This fix checks if the session is in "completing" status (indicating an intentional interrupt) before marking it as failed, eliminating the transient failed status in the UI.
This commit is contained in:
@@ -277,7 +277,17 @@ eventLoop:
|
||||
|
||||
endTime := time.Now()
|
||||
if err != nil {
|
||||
m.updateSessionStatus(ctx, sessionID, StatusFailed, err.Error())
|
||||
// Check if this was an intentional interrupt
|
||||
session, dbErr := m.store.GetSession(ctx, sessionID)
|
||||
if dbErr == nil && session != nil && session.Status == string(StatusCompleting) {
|
||||
// This was an interrupted session, not a failure
|
||||
// Let it transition to completed naturally
|
||||
slog.Debug("session was interrupted, not marking as failed",
|
||||
"session_id", sessionID,
|
||||
"status", session.Status)
|
||||
} else {
|
||||
m.updateSessionStatus(ctx, sessionID, StatusFailed, err.Error())
|
||||
}
|
||||
} else if result != nil && result.IsError {
|
||||
m.updateSessionStatus(ctx, sessionID, StatusFailed, result.Error)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user