GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — mcpx(daemon): chat-completions proxy has no upstream timeout and buffers the whole upstream response in memory — proxyToUpstream uses http.DefaultClient and an uncapped TeeReader buffer · Issue #2114 · developing-today/code

mcpx(daemon): chat-completions proxy has no upstream timeout and buffers the whole upstream response in memory — proxyToUpstream uses http.DefaultClient and an uncapped TeeReader buffer #2114

New issue
Copy link
New issue
Copy link
Closed
Closed
mcpx(daemon): chat-completions proxy has no upstream timeout and buffers the whole upstream response in memory — proxyToUpstream uses http.DefaultClient and an uncapped TeeReader buffer#2114
Copy link
Assignees
dezren39
Labels
app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobsource/design-architectFiled by the repo design architect jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Description

@dezren39
dezren39
opened on Oct 29, 2026
Issue body actions

Problem

The mcpx daemon's chat-completions reverse proxy (proxyToUpstream, pkgs/mcpx/internal/daemon/routes_proxy.go:215) has no bound on either direction of its upstream call:

1. No upstream timeout. routes_proxy.go:237 calls http.DefaultClient.Do(upReq). http.DefaultClient has no Timeout, and the client sets no ResponseHeaderTimeout — the only cancellation is the inbound request's context, i.e. the downstream client disconnecting. The daemon's own HTTP servers set only ReadHeaderTimeout (internal/daemon/server.go:309,361) — no write/response deadline rescues a stuck handler. An upstream that accepts the connection and never answers (or trickles forever) holds the handler, its goroutine and the downstream connection indefinitely. This is reachable per-request: handleChatCompletions takes the upstream URL from the X-Upstream-Url request header when present (routes_proxy.go, step 4, ~:150), so any local client can aim the daemon at a slow-loris endpoint.

2. The whole upstream response is buffered in memory, uncapped. routes_proxy.go:245-262: the response body is streamed through an io.TeeReader into a bytes.Buffer, then buf.String() is stored as the feedback interaction record after io.Copy finishes. The copy itself streams, but the buffer defeats it — memory grows with the full response size, with no cap. A streamed request makes this worst-case: chatCompletionReq.Stream (routes_proxy.go:38) is marshalled straight into the proxied payload (:227) and handleChatCompletions proxies unconditionally (:164), so a long SSE stream accumulates in the buffer for its entire life.

Verified on main 42796be5bbe8824545df570f3b239d23d4ef93ac by reading the code this run.

The house pattern this misses

Every other outbound HTTP call in mcpx pins a timeout or a body bound:

  • internal/catalog/embeddings.go:52 — &http.Client{Timeout: defaults.EmbeddingsRemoteTimeout}
  • internal/mcpclient/sse.go:58 — &http.Client{Timeout: timeout}; error bodies read via io.LimitReader(..., defaults.HTTPErrorBodyLimit) (sse.go:76,225)
  • internal/cli/client.go:118-162 — all daemon clients built with explicit timeouts
  • internal/daemon/ops.go:285 — registry calls use cs.Duration("registry.timeout")

routes_proxy.go:237 is the only http.DefaultClient use in internal/daemon.

Why it matters

The daemon is the process every other tool call depends on. One hung upstream (a crashed provider gateway, a misconfigured proxy.upstreamUrl, a header-aimed slow endpoint) leaks a handler + connection pair forever per request, and one large or streamed response can grow daemon memory without limit — the daemon-side mirror of the inbound body-cap gap in #2082 (request bodies), on the response path #2082 does not cover. Distinct from #2097/#2100/#2102: those are the standalone proxy packages; this is mcpx's own daemon proxy route.

Acceptance criteria

  • proxyToUpstream uses a client with a configured timeout (a proxy.* setting with a sane default, in the style of registry.timeout / defaults.EmbeddingsRemoteTimeout), covering at least time-to-headers and total response time; a timed-out upstream yields a clean 502 to the downstream client.
  • The feedback-record copy of the upstream response is capped (e.g. io.LimitReader at a named constant, in the spirit of defaults.HTTPErrorBodyLimit); over-cap responses are still proxied in full to the client, only the recorded copy is truncated, and the truncation is visible in the record.
  • Tests: a stub upstream that accepts and never responds makes the handler return within the configured timeout; a stub upstream returning an over-cap (or streamed) response is proxied completely while daemon-side buffering stays bounded.
  • Existing daemon test suites pass unchanged.

Activity

Next
  1. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    status/needs-triageNot yet triaged; needs a first look
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    on Oct 29, 2026
  2. developing-today commented on Oct 29, 2026

    @developing-today
    developing-todayBot
    on Oct 29, 2026 – with developing.today
    Contributor
    More actions

    CODE-1017

  3. dezren39
    added
    queue/queuedHas a queued queue task
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    on Oct 29, 2026
  4. dezren39 commented on Oct 29, 2026

    @dezren39
    dezren39
    on Oct 29, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator-code-a (new-issue-creator, lane A)
    • Session / ID: cron run 2026-10-28 23:35 CDT (America/Chicago)
    • Found via: filed this run
    • Task: Filed after verifying on main 42796be: proxyToUpstream (routes_proxy.go:237) uses http.DefaultClient (no timeout; daemon servers pin only ReadHeaderTimeout) and TeeBuffers the entire upstream response uncapped for the feedback record (:245-262), including streamed requests. House contrast: catalog/embeddings.go:52, mcpclient/sse.go:58, cli/client.go:118-162 all pin timeouts/bounds. Deduped against mcpx(daemon): a second set of routes reads request bodies with no size ceiling — chat completions, exec, intent, upgrade and five more bypass the configured http.*BodyLimit caps #2082 (inbound request-body caps — different path) and design-code-proxy: backend dispatch has no timeout — a backend that accepts and never responds hangs the request forever and the fallback never fires #2097/clef-proxy: data-path upstream fetch has no timeout — a gateway that accepts and never responds holds the /v1/systemone request open (models fetch in the same file pins 10s) #2100/antigravity-ls-proxy: callRpc has no timeout — a language server that heartbeats but never answers an RPC hangs /v1/models and every chat request forever #2102 (standalone proxy packages).
    • Expectation: effort/s small-fix — configured upstream timeout + capped feedback-record copy, with stub-upstream tests; queued for the repo worker, not self-solved (timeout semantics need a settings decision).
    • Links: queue packet enqueued this run (dedupe repo-health:v1:fix:developing-today/code:issue:2114)
  5. github-actions
    assigned
    dezren39
    on Oct 29, 2026
  6. dezren39
    added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    queue/queuedHas a queued queue task
    on Nov 1, 2026
  7. 55 remaining items

  8. dezren39
    added
    status/in-progressQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 3, 2026
  9. dezren39 commented on Nov 3, 2026

    @dezren39
    dezren39
    on Nov 3, 2026
    MemberAuthor
    More actions

    🤖 Agent note · parked

    • Agent: queue worker (repo-worker-code), lane code-e
    • Session / ID: task 8803
    • Found via: queue claim (resume from awaiting_ci)
    • Task: task 8803 parked 20 minutes: PR mcpx(daemon): bound chat proxy upstream calls (#2114) #3380 (issue mcpx(daemon): chat-completions proxy has no upstream timeout and buffers the whole upstream response in memory — proxyToUpstream uses http.DefaultClient and an uncapped TeeReader buffer #2114) is MERGEABLE/CLEAN with both basic checks SUCCESS, but the Codex re-review of head 90bb132 requested in PR comment 6617846850 has not completed yet. The sole Codex finding on the prior head (P1, compendium manifest) was fixed in 90bb132 and dispositioned at 4461138750.
    • Expectation: resume condition = Codex re-review of head 90bb132 completes with no undispositioned findings; then merge PR mcpx(daemon): bound chat proxy upstream calls (#2114) #3380 and complete task 8803 as fixed_merged (issue mcpx(daemon): chat-completions proxy has no upstream timeout and buffers the whole upstream response in memory — proxyToUpstream uses http.DefaultClient and an uncapped TeeReader buffer #2114 closes via the PR).
    • Links: issue mcpx(daemon): chat-completions proxy has no upstream timeout and buffers the whole upstream response in memory — proxyToUpstream uses http.DefaultClient and an uncapped TeeReader buffer #2114; PR mcpx(daemon): bound chat proxy upstream calls (#2114) #3380
  10. dezren39
    added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    on Nov 3, 2026
  11. dezren39
    added a commit that references this issue on Nov 3, 2026

    Merge pull request #3380 from developing-today/queue/3088-2114-proxy-…

    0b44df8
  12. dezren39 commented on Nov 3, 2026

    @dezren39
    dezren39
    on Nov 3, 2026
    MemberAuthor
    More actions

    🤖 Agent note · done

    • Agent: queue worker (repo-worker-code), lane code-d
    • Session / ID: task 8803
    • Found via: queue claim (resume from park)
    • Task: PR mcpx(daemon): bound chat proxy upstream calls (#2114) #3380 MERGED (merge commit 0b44df8, 2026-11-03T23:36Z). Codex re-review of head 90bb132 landed clean ("Didn't find any major issues", 23:12Z); both basic checks SUCCESS. The PR implements issue mcpx(daemon): chat-completions proxy has no upstream timeout and buffers the whole upstream response in memory — proxyToUpstream uses http.DefaultClient and an uncapped TeeReader buffer #2114's acceptance: proxy.timeout setting with clean 502 on upstream timeout, feedback copy capped at 1 MiB with a visible truncation marker (proxied stream untruncated), stub-upstream tests for both (evidence in the PR body). Closing issue mcpx(daemon): chat-completions proxy has no upstream timeout and buffers the whole upstream response in memory — proxyToUpstream uses http.DefaultClient and an uncapped TeeReader buffer #2114 as fixed.
  13. dezren39
    closed this as completedon Nov 3, 2026
  14. dezren39
    removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    status:in-review
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobsource/design-architectFiled by the repo design architect jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.