Skip to content

codedb-bridge: daemon fetch has no timeout — a hung daemon hangs the call forever and blocks bridge exit on stdin close #4191

Closed

Description

@dezren39

Problem

bin/codedb-bridge.mjs (new in PR #4171, for issue #4120) calls the codedb daemon with no timeout anywhere:

  • createHandler's callTool awaits the fetch with no signal: bin/codedb-bridge.mjs:192 — res = await fetchFn(\${daemonUrl}${mapped.route}`)`.
  • main wires the real fetch the same way: bin/codedb-bridge.mjs:251 — fetchFn: (url) => fetch(url) — no AbortSignal.timeout(...), no AbortController, no deadline constant anywhere in the file.

A daemon that accepts the connection but never responds (wedged index rebuild, half-open socket, a daemon stuck behind a lock) therefore hangs that tools/call forever.

Why it matters

  1. The caller never gets an error it can act on — not even the bridge's own "daemon unreachable" message (:194-199), which only covers a rejected fetch. The line-293 comment says "the caller times out on that one id", but nothing in the bridge ever resolves that id.
  2. It defeats the bridge's own exit path: main's maybeExit (:261-262) refuses to exit while pending !== 0, and a hung call never settles (:269-271). So after the MCP client closes stdin, the bridge process leaks indefinitely instead of exiting — exactly the per-session process accumulation the bridge was built to eliminate (codedb shared daemon + MCP bridge: one codedb serve per project root, lift the #2220 park in the new shape (#2225) #4120 / Determine how to not need multiple codedb instances — or replace codedb effectively #2225).
  3. The shared-bridge design (mcpx can share one bridge across sessions, :255-258) makes one wedged daemon call a standing leak for every session that touches it.

Evidence (verified this run)

Laptop probe ~/git/fleet/probe-2026-11-01-laneA-codedb/ (verbatim copy of bin/codedb-bridge.mjs from main 199a7d27, md5 ca05ede20d2ae1a4760297bbe9320c58 on both hosts, node v24.21.0):

  • createHandler with a never-resolving fetchFn: the tools/call promise was STILL-PENDING after 600 ms (and by construction pending forever — no timer exists in the code path).
  • grep over the file: no AbortSignal, AbortController, timeout, or setTimeout outside the tests.

Distinct from issue #2114 (mcpx's Go chat-completions proxy upstream timeout — a different component and language).

Acceptance criteria

  • A daemon fetch is bounded by a deadline (a named constant; configurable via env if that fits the existing CODEDB_DAEMON_URL config style).
  • On expiry the tools/call returns an MCP error result (isError: true) naming the daemon URL, the route, and the timeout — the caller can retry or restart the daemon.
  • After stdin closes, the bridge exits even if a call was hung (the hung call is aborted/settled, so pending reaches 0).
  • New test in bin/codedb-bridge.test.mjs: a stub daemon/fetch that never responds produces the timeout error within a bounded, test-scale time; the existing slow-but-finite test (1.2 s daemon delay, PR feat(mcpx): codedb shared daemon + stdio MCP bridge — lift the #2220 park (#4120, #2225) #4171) and the stdin-close flush test still pass — pick the default deadline comfortably above legitimate slow daemon responses.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    app/codedb-bridgebin/codedb-bridge.mjs — stdio MCP bridge to the shared codedb daemon
    on Nov 2, 2026
  2. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-a)
    • Session / ID: new-issue-creator-code-a run 2026-11-01 23:05 CST (2026-11-02T05:09Z)
    • Found via: filed this run
    • Task: Triage the missing daemon-fetch timeout in bin/codedb-bridge.mjs and route the bounded-fetch fix
    • Expectation: effort/s — done when a hung daemon produces a named timeout error and the bridge can exit after stdin close, with tests
    • Links: evidence in the issue body; laptop probe ~/git/fleet/probe-2026-11-01-laneA-codedb/
  3. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 2, 2026
  5. 63 remaining items

  6. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  7. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up (resume)

  8. added
    queue/blockedQueue or user escalation state
    status/blockedQueue or user escalation state
    user/escalatedRequires a Drew decision or access
    and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 3, 2026
  9. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · escalated (blocked: Drew decision required)

  10. removed
    status/blockedQueue or user escalation state
    user/escalatedRequires a Drew decision or access
    queue/blockedQueue or user escalation state
    on Nov 8, 2026
  11. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    Agent note — task 13402 done: PR #4561 merged, issue #4191 closed (lane code-w, direct, pr_shepherd)

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

Metadata

Metadata

Assignees

Labels

app/codedb-bridgebin/codedb-bridge.mjs — stdio MCP bridge to the shared codedb daemoneffort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions