Skip to content
This repository was archived by the owner on Apr 5, 2026. It is now read-only.

Commit 4cb8b13

Browse files
HerbHallclaude
andauthored
fix: errcheck file handles in GO-CI checklist + MCP hang prevention (#391)
GO-CI checklist (#388): expand bodyclose bullet to include file handles (os.Open, defer f.Close) alongside HTTP response bodies. Agents kept missing this surface despite AP#19 documenting the pattern. Autolearn MCP hang (#389): add explicit pre-check instructions to session-review.md and quick-reflect.md -- verify mcp__sqlite__* tools are available before calling. stdio MCP servers hang indefinitely when unavailable. Add KG#155 documenting the broader stdio MCP hang gotcha. Closes #388, Closes #389 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3e7cffe commit 4cb8b13

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

claude/rules/known-gotchas.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Known gotchas and platform-specific issues. Read when debugging unexpected behavior.
33
tier: 2
4-
entry_count: 56
4+
entry_count: 57
55
last_updated: "2026-03-17"
66
---
77

@@ -613,3 +613,11 @@ Windows CRLF (`\r\n`) causes silent failures across multiple tools. Three known
613613
**Issue:** Gitea Actions runner actcache at `/home/git/.cache/actcache/cache` grows ~650MB per CI run with no automatic eviction. Combined with trivy temp files and Go build cache, disk fills completely. Gitea returns "database or disk is full" on merge API calls.
614614
**Fix:** Periodic cleanup via cron: `find /home/git/.cache/actcache/cache -maxdepth 1 -mtime +7 -exec rm -rf {} +`. Also clean `/tmp/tmp.*` and Go build cache.
615615
**See also:** KG#148 (archived, trivy binary accumulation -- same root cause)
616+
617+
## 155. stdio MCP Servers Hang Indefinitely When Unavailable
618+
619+
**Added:** 2026-03-17 | **Source:** Samverk | **Status:** active
620+
621+
**Platform:** Claude Code (all)
622+
**Issue:** stdio-based MCP servers (sqlite, memory, sequential-thinking, context7, ms365-onenote) hang indefinitely when they fail to initialize (wrong path, missing auth, process crash). Tool calls never return and the session must be manually cancelled. The "If unavailable, skip" instruction in workflows has no way to detect unavailability before attempting the call.
623+
**Fix:** Before calling any stdio MCP tool, verify it appears in the available tools list. If not listed, skip the call entirely. For workflows, add explicit pre-check instructions. HTTP-based MCP servers (Synapset) fail fast with connection errors instead of hanging.

claude/rules/subagent-ci-checklist.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Common Go CI failures to watch for:
9797
- gocritic unnamedResult: Functions returning multiple values need named returns. After adding names, change `:=` to `=` for those variables AND remove redundant `var` declarations for those names.
9898
- gocritic appendCombine: Two consecutive `append()` to the same slice must be combined into one call with multiple elements.
9999
- gocritic rangeValCopy: Use `for i := range slice` with `slice[i]` instead of `for _, v := range slice` for large structs.
100-
- bodyclose: Always close `*http.Response` body, including from `websocket.Dial()`.
100+
- bodyclose/errcheck: Always close HTTP response bodies AND file handles. Direct: `_ = f.Close()`. Deferred: `defer func() { _ = f.Close() }()`. Applies to `os.Open`, `resp.Body`, `websocket.Dial`.
101101
- Build-tag files (!windows): Lint errors only show in Linux CI. Check for filepathJoin, G115, paramTypeCombine.
102102
- exhaustive: Switch on enum types MUST list ALL cases, even with a default return. Group non-matching cases on 2-3 lines.
103103
- prealloc: `var slice []T` in a loop body should be `make([]T, 0, len(source))`.
@@ -112,7 +112,7 @@ Backend:
112112
1. `go build ./...` && `go test ./...`
113113
2. If HTTP handlers added: `go run github.com/swaggo/swag/cmd/swag@v1.16.4 init -g cmd/<app>/main.go -o api/swagger --parseDependency --parseInternal`
114114
3. Self-check: `for _, v := range` on large structs -> index-based; `var []T` -> `make([]T, 0, cap)`; consecutive appends -> combine; unnamed multi-returns -> name them
115-
4. Watch for: gosec G101, gocritic unnamedResult (`:=` -> `=` + remove `var` after named returns), gocritic appendCombine, bodyclose, exhaustive (all enum cases in switch)
115+
4. Watch for: gosec G101, gocritic unnamedResult (`:=` -> `=` + remove `var` after named returns), gocritic appendCombine, bodyclose/errcheck (file handles + response bodies), exhaustive (all enum cases in switch)
116116
117117
Frontend:
118118
1. If deps changed: `cd web && pnpm install` to sync lockfile

claude/skills/autolearn/workflows/quick-reflect.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ Scan the conversation for patterns that were actively used to solve a problem or
9595
1. **Rules file references**: Look for AP#N or KG#N citations in the conversation
9696
2. **Synapset search results**: Look for `search_memory` or `search_all` tool calls where a returned result influenced the solution. Use the memory ID as `SYN#<id>` (e.g., `SYN#412`)
9797

98-
For each pattern that helped, record an application event using SQLite MCP:
98+
For each pattern that helped, record an application event using SQLite MCP.
99+
100+
**Pre-check:** Before calling any `mcp__sqlite__*` tool, verify it appears in your available tools. If not listed, skip step 5b entirely. Do NOT attempt the call -- stdio MCP servers hang indefinitely when unavailable.
99101

100102
```text
101103
write_query(database: "claude.db", query: "CREATE TABLE IF NOT EXISTS pattern_events (id INTEGER PRIMARY KEY AUTOINCREMENT, entry_id TEXT NOT NULL, entry_title TEXT, event_type TEXT NOT NULL, project TEXT, session_date TEXT NOT NULL, description TEXT, source TEXT); INSERT INTO pattern_events (entry_id, entry_title, event_type, project, session_date, description, source) VALUES ('<AP#N, KG#N, or SYN#id>', '<title>', '<prevented|caught|applied>', '<project>', datetime('now'), '<brief note>', '<rules-file|synapset>');"

claude/skills/autolearn/workflows/session-review.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ Scan the conversation for patterns that were actively used to solve a problem or
130130
1. **Rules file references**: Look for AP#N or KG#N citations in the conversation
131131
2. **Synapset search results**: Look for `search_memory` or `search_all` tool calls where a returned result influenced the solution. Use the memory ID as `SYN#<id>` (e.g., `SYN#412`)
132132

133-
For each pattern that helped, record an application event using SQLite MCP:
133+
For each pattern that helped, record an application event using SQLite MCP.
134+
135+
**Pre-check:** Before calling any `mcp__sqlite__*` tool, verify it appears in your available tools. If not listed, skip steps 5b and 5c entirely. Do NOT attempt the call -- stdio MCP servers hang indefinitely when unavailable.
134136

135137
```text
136138
write_query(database: "claude.db", query: "CREATE TABLE IF NOT EXISTS pattern_events (id INTEGER PRIMARY KEY AUTOINCREMENT, entry_id TEXT NOT NULL, entry_title TEXT, event_type TEXT NOT NULL, project TEXT, session_date TEXT NOT NULL, description TEXT, source TEXT); INSERT INTO pattern_events (entry_id, entry_title, event_type, project, session_date, description, source) VALUES ('<AP#N, KG#N, or SYN#id>', '<title>', '<prevented|caught|applied>', '<project>', datetime('now'), '<brief note>', '<rules-file|synapset>');"

0 commit comments

Comments
 (0)