Skip to content

fix(stack): pool gateway writes on keep-alive connections (CLI-2623) - #7075

Merged
7ttp merged 2 commits into
developfrom
7ttp/cli-2623-stack-gateway-still-opens-a-new-upstream-connection-per
Oct 9, 2026
Merged

7ttp merged 2 commits into
developfrom
7ttp/cli-2623-stack-gateway-still-opens-a-new-upstream-connection-per

Conversation

@7ttp

@7ttp 7ttp commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

TL;DR

stops the local stack gateway from opening a new upstream connection for every write.

whats broken?

every .rpc(), auth.admin.createUser, delete or upload went upstream on its own connection and left it in TIME_WAIT, so a busy test run used up the macOS port range.

now fixed by:

writes reuse the gateway's keep alive pool like reads do. a write is still never resent.
Studio and its /mcp route keep a fresh connection per write, as before

chunked GET and DELETE bodies are forwarded as chunked, so they reach the upstream and stay off the next request
PS: Auth's own Postgres churn is tracked in #6981

ref:

@7ttp 7ttp self-assigned this Oct 9, 2026
@7ttp
7ttp requested a review from a team as a code owner October 9, 2026 10:24

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 AI Review

Both independent reviews were available. Claude's finding is confirmed as a minor reliability trade-off: pooled writes can fail on a stale connection without retry. Studio's fresh-connection exception is correctly propagated. No additional findings were identified. Tests were inspected but not run.

Findings

Severity Location Category Sources Claim
🟡 MINOR packages/stack/src/HttpProxy.ts:433 reliability claude Writes on routes without freshWrites now reuse pooled upstream connections. If an upstream closes a connection as it is reused, the write fails with 502 without retry. Previously, writes used fresh connections and avoided this particular failure mode. The four-second agent timeout mitigates idle-timeout races but cannot eliminate connection-reset races.

Stats

Claude findings: 1 · Codex findings: 0 · Confirmed: 1 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread packages/stack/src/HttpProxy.ts
Comment thread packages/stack/src/HttpProxy.integration.test.ts Outdated
@7ttp
7ttp enabled auto-merge October 9, 2026 14:19
@7ttp
7ttp added this pull request to the merge queue Oct 9, 2026
Merged via the queue into develop with commit 09ed2bd Oct 9, 2026
33 checks passed
@7ttp
7ttp deleted the 7ttp/cli-2623-stack-gateway-still-opens-a-new-upstream-connection-per branch October 9, 2026 14:35
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.

stack: gateway still opens a new upstream connection per request on 2.119.0 (exhausts ephemeral ports on macOS)

2 participants