Fix tasks board WS idle timeouts and Mira pipeline kicks.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Reset read deadline on server Ping (not only Pong), run OnEvent async so long replies do not stall the socket, and always answer clear Mira delivery asks instead of LLM decide-gate skips.
This commit is contained in:
alex 2026-09-22 12:45:44 +03:00
parent 264795613c
commit 856e5a3cab

View File

@ -111,6 +111,12 @@ func (c *Client) session(ctx context.Context, since *int64) error {
defer conn.Close() defer conn.Close()
_ = conn.SetReadDeadline(time.Now().Add(90 * time.Second)) _ = conn.SetReadDeadline(time.Now().Add(90 * time.Second))
// Server sends Ping; gorilla delivers it as Ping (not Pong). Reset deadline or
// idle boards die every ~90s with "i/o timeout" despite healthy pings.
conn.SetPingHandler(func(appData string) error {
_ = conn.SetReadDeadline(time.Now().Add(90 * time.Second))
return conn.WriteControl(websocket.PongMessage, []byte(appData), time.Now().Add(10*time.Second))
})
conn.SetPongHandler(func(string) error { conn.SetPongHandler(func(string) error {
_ = conn.SetReadDeadline(time.Now().Add(90 * time.Second)) _ = conn.SetReadDeadline(time.Now().Add(90 * time.Second))
return nil return nil
@ -146,9 +152,13 @@ func (c *Client) session(ctx context.Context, since *int64) error {
*since = ev.Seq *since = ev.Seq
} }
if c.OnEvent != nil { if c.OnEvent != nil {
if err := c.OnEvent(ctx, ev); err != nil && c.Log != nil { ev := ev
hctx := context.WithoutCancel(ctx)
go func() {
if err := c.OnEvent(hctx, ev); err != nil && c.Log != nil {
c.Log.Warn("tasks ws handler", "error", err, "type", ev.Type) c.Log.Warn("tasks ws handler", "error", err, "type", ev.Type)
} }
}()
} }
} }
} }