From 69dae103db0ff503c36ac425d38dbbcfe3ad9d6a Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 10 Jan 2026 13:35:30 -0800 Subject: [PATCH] fix: add timeout to daemon request context to prevent indefinite hangs reqCtx() now applies the server's requestTimeout (default 30s) to the context returned for request handlers. This prevents bd list and other commands from hanging indefinitely when database operations stall. The fix ensures: - All RPC handlers get a context with a deadline - Database operations (using QueryContext) honor context cancellation - reconnectMu read locks are released when context times out Fixes: bd-p76kv Co-Authored-By: Claude Opus 4.5 Executed-By: beads/crew/dave Rig: beads Role: crew --- internal/rpc/server_routing_validation_diagnostics.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/rpc/server_routing_validation_diagnostics.go b/internal/rpc/server_routing_validation_diagnostics.go index 3e51657f..d725ba03 100644 --- a/internal/rpc/server_routing_validation_diagnostics.go +++ b/internal/rpc/server_routing_validation_diagnostics.go @@ -259,8 +259,13 @@ func (s *Server) handleRequest(req *Request) Response { } // Adapter helpers + +// reqCtx returns a context with the server's request timeout applied. +// This prevents request handlers from hanging indefinitely if database +// operations or other internal calls stall (GH#bd-p76kv). func (s *Server) reqCtx(_ *Request) context.Context { - return context.Background() + ctx, _ := context.WithTimeout(context.Background(), s.requestTimeout) + return ctx } func (s *Server) reqActor(req *Request) string {