Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(daemon): log HTTP claim result after uncertain WebSocket claim (#10987)

Danila Katalshovf58a87bd48e6
diff --git a/server/internal/daemon/daemon_legacy_fallback_test.go b/server/internal/daemon/daemon_legacy_fallback_test.go
index b794d3f91f..998278a996 100644
--- a/server/internal/daemon/daemon_legacy_fallback_test.go
+++ b/server/internal/daemon/daemon_legacy_fallback_test.go
@@ -1,6 +1,7 @@
package daemon
import (
+ "bytes"
"context"
"log/slog"
"net/http"
@@ -160,7 +161,8 @@ func TestClaimTasksWSFirst_HTTPFallbackAfterUncertainCooldown(t *testing.T) {
}))
defer srv.Close()
- d := New(Config{ServerBaseURL: srv.URL, MaxConcurrentTasks: 4}, slog.New(slog.NewTextHandler(noopWriter{}, nil)))
+ var logs bytes.Buffer
+ d := New(Config{ServerBaseURL: srv.URL, MaxConcurrentTasks: 4}, slog.New(slog.NewTextHandler(&logs, &slog.HandlerOptions{Level: slog.LevelDebug})))
var mu sync.Mutex
var item *wsOutbound
@@ -238,6 +240,9 @@ func TestClaimTasksWSFirst_HTTPFallbackAfterUncertainCooldown(t *testing.T) {
if wsClaims.Load() != 0 {
t.Fatalf("WS claims after uncertain cooldown = %d, want 0", wsClaims.Load())
}
+ if !strings.Contains(logs.String(), "http claim after uncertain ws outcome completed") || !strings.Contains(logs.String(), "task_count=1") {
+ t.Fatal("expected the HTTP recovery result and its task count in the debug log")
+ }
}
// TestClaimTasksWSFirst_ReconnectToOldServerSkipsWSRPC pins compatibility when
diff --git a/server/internal/daemon/wsrpc.go b/server/internal/daemon/wsrpc.go
index 3a1cef063f..fca9e79af4 100644
--- a/server/internal/daemon/wsrpc.go
+++ b/server/internal/daemon/wsrpc.go
@@ -397,6 +397,9 @@ func (d *Daemon) claimTasksWSFirst(ctx context.Context, daemonID string, runtime
}
result, err := d.client.claimTasksWithHints(ctx, daemonID, runtimeIDs, maxTasks, forceRecheckIDs...)
if err == nil {
+ if bypassWSOnce {
+ d.logger.Debug("http claim after uncertain ws outcome completed", "runtime_count", len(runtimeIDs), "task_count", len(result.Tasks))
+ }
return result, nil
}
// Server has no batch route (404): freeze the old API contract by falling