Skip to content

fix: increase MCP idle timeout to 10 minutes (#148)#166

Open
justrach wants to merge 2 commits intomainfrom
fix/148-timeout
Open

fix: increase MCP idle timeout to 10 minutes (#148)#166
justrach wants to merge 2 commits intomainfrom
fix/148-timeout

Conversation

@justrach
Copy link
Copy Markdown
Owner

@justrach justrach commented Apr 6, 2026

Summary

Fixes #148 — MCP server disconnects during debugging sessions + orphaned processes linger.

Two fixes:

1. Idle timeout: 2min → 10min
Agents thinking for >2min during debugging would lose the MCP connection. 10 minutes is enough for any debugging session.

2. stdin poll for dead client detection
Watchdog now polls stdin every 10 seconds for POLLHUP. When the client pipe closes (crash, kill, disconnect), server exits within 10 seconds — no more dangling processes.

Behavior matrix:

Scenario What happens Exit time
Client disconnects cleanly stdin EOF Immediate
Client crashes/killed POLLHUP detected ≤10 seconds
Client connected but idle 10min timeout 10 minutes
Orphaned (no client ever) 10min timeout 10 minutes

Why this is safe:

  • stdin EOF still exits immediately via the main MCP read loop
  • POLLHUP catches cases where stdin stays "open" but the client is gone
  • 10min is generous enough for debugging but still cleans up orphans

1 file changed, ~20 lines.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

Benchmark Regression Report

Threshold: 10.00%

Tool Base (ns) Head (ns) Delta Status
codedb_bundle 621987 626185 +0.67% OK
codedb_changes 108751 117851 +8.37% OK
codedb_deps 30720 32003 +4.18% OK
codedb_edit 17535 17943 +2.33% OK
codedb_hot 161938 160968 -0.60% OK
codedb_outline 401253 407089 +1.45% OK
codedb_read 170009 166593 -2.01% OK
codedb_search 255751 262893 +2.79% OK
codedb_snapshot 3462658 3534808 +2.08% OK
codedb_status 28285 29226 +3.33% OK
codedb_symbol 62089 61366 -1.16% OK
codedb_tree 80249 80937 +0.86% OK
codedb_word 92130 92678 +0.59% OK

Two changes:
1. Idle timeout increased from 2min to 10min — allows long debugging
   sessions where the agent thinks for >2min
2. Watchdog now polls stdin every 10s for POLLHUP — detects dead clients
   immediately instead of waiting for the full timeout. When the client
   pipe closes, server exits within 10 seconds.

This means:
- Client disconnects cleanly → stdin EOF → server exits immediately
- Client crashes/killed → POLLHUP detected → server exits in ≤10s
- Client connected but idle → 10min timeout (plenty for debugging)
- Orphaned process (no client ever) → 10min timeout

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

Benchmark Regression Report

Threshold: 10.00%

Tool Base (ns) Head (ns) Delta Status
codedb_bundle 645800 615901 -4.63% OK
codedb_changes 111295 107266 -3.62% OK
codedb_deps 34465 29855 -13.38% OK
codedb_edit 17476 17586 +0.63% OK
codedb_hot 160919 162053 +0.70% OK
codedb_outline 383892 383679 -0.06% OK
codedb_read 165333 171138 +3.51% OK
codedb_search 256911 252397 -1.76% OK
codedb_snapshot 3501637 3469508 -0.92% OK
codedb_status 29236 29389 +0.52% OK
codedb_symbol 62081 59374 -4.36% OK
codedb_tree 81020 85217 +5.18% OK
codedb_word 92507 90240 -2.45% OK

- Verify idle_timeout_ms is 10 minutes (600,000ms)
- Verify POLLHUP detected when pipe write end is closed (client gone)
- Verify open pipe does NOT trigger false HUP

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

Benchmark Regression Report

Threshold: 10.00%

Tool Base (ns) Head (ns) Delta Status
codedb_bundle 614701 612400 -0.37% OK
codedb_changes 109266 108125 -1.04% OK
codedb_deps 29699 31582 +6.34% OK
codedb_edit 17162 15987 -6.85% OK
codedb_hot 158480 159936 +0.92% OK
codedb_outline 403952 384902 -4.72% OK
codedb_read 164353 171103 +4.11% OK
codedb_search 252426 257065 +1.84% OK
codedb_snapshot 3464697 3491893 +0.78% OK
codedb_status 30412 27917 -8.20% OK
codedb_symbol 62942 61583 -2.16% OK
codedb_tree 80514 85588 +6.30% OK
codedb_word 90855 89491 -1.50% OK

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 252a9f1fed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Wait up to 15 seconds for the process to exit
// (watchdog polls every 10s, so it should detect POLLHUP within ~10s)
const start = std.time.milliTimestamp();
const term = child.wait() catch {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add a real timeout when waiting for MCP child exit

This test claims to "wait up to 15 seconds," but child.wait() is unbounded and can block forever. If codedb mcp fails to exit after stdin closes (the exact regression this test is meant to catch), the test will hang the suite/CI instead of failing fast. Please use a deadline-based wait loop (e.g., tryWait + sleep, then kill/fail at 15s) so timeouts are enforced.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

timeout issue

1 participant