End every wait in flight when the tool runner stops (issue 745)
mesh/merge-gate head 21d038d3397c merged into trunk 5d70eb3e35a9 — pass, with a note: builds mesh-tools, node-tools (+39 dependent(s)) → ace, g14, novox, s…
mesh/repo-check head 21d038d3397c merged into trunk 5d70eb3e35a9 — pass: THE CHANGE ALTERS ITS OWN CHECK (merge-check.sh): main's version judged it; the ch…
mesh/delivery delivered

Closing the console shut its server down with a context that never ends, so a stop or restart of
the tool runner waited on any mesh_wait in flight for up to ten minutes. The server's base context
is now cancelled first, ending every wait at once, with a five-second shutdown as a backstop
(second review of issue 745).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 00:47:59 +00:00
co-authored by Claude Opus 5.5
parent 5d70eb3e35
commit 21d038d339
12 changed files with 775 additions and 18 deletions
+9 -3
View File
@@ -4,6 +4,7 @@
package console
import (
"context"
"encoding/json"
"os"
"strings"
@@ -103,7 +104,11 @@ func idOrNull(id json.RawMessage) json.RawMessage {
}
// Handle answers one request; nil for a notification, which expects none.
func (s *Surface) Handle(r Request) *Reply {
func (s *Surface) Handle(r Request) *Reply { return s.HandleContext(context.Background(), r) }
// HandleContext answers one request for as long as ctx lasts: a wait whose client hung up or cancelled
// ends at once, its subscription closed (the review of issue 745).
func (s *Surface) HandleContext(ctx context.Context, r Request) *Reply {
notification := isNotification(r.ID)
switch r.Method {
case "initialize":
@@ -164,7 +169,7 @@ func (s *Surface) Handle(r Request) *Reply {
if p.Arguments == nil {
p.Arguments = map[string]any{}
}
return answer(r.ID, s.discover(p.Name, p.Arguments))
return answer(r.ID, s.discover(ctx, p.Name, p.Arguments))
}
args := map[string]any{}
for k, v := range p.Arguments {
@@ -305,7 +310,8 @@ func (s *Surface) instructions() string {
"whole (novox/hq ADR 0195). mesh_overview shows the mesh's seats and machines; mesh_machine one " +
"machine's seats and modules; mesh_search finds a tool by words; mesh_describe gives one tool's " +
"arguments; mesh_call calls it; mesh_runtimes says which machines' runtimes answered discovery, how fast " +
"and how much — ask it when an address is said to be missing or on another machine. " + grammar + " What may be called was fixed when this account " +
"and how much — ask it when an address is said to be missing or on another machine; mesh_wait waits on the " +
"bus for an event instead of polling (novox/hq ADR 0367). " + grammar + " What may be called was fixed when this account " +
"was issued, so a refusal means the account, not the tool."
}