pi-mono/packages
robopipi[bot] 63ea042ce5
fix(mcp): close remaining connections when the OAuth callback server closes (#11855)
After a successful MCP OAuth sign-in, `/mcp login` could stay on
"Connecting…" for minutes. `OAuthCallbackServer.close()` awaited
`http.Server.close()`, which resolves only after every socket has
closed. Browsers may keep an unused connection open to the callback port
(a preconnect, or a spare keep-alive socket). Node's idle-connection
cleanup doesn't close that socket, and `close()` also stops Node's
request timeout checks. So the wait lasted until the browser dropped the
socket. `signInMcpServer` awaits this cleanup before reconnecting, and
cancellation doesn't apply to it, so Ctrl+C did nothing.

`close()` now calls `server.closeAllConnections()` after starting the
shutdown. By the time the server closes, the callback response has
already been sent, so dropping the remaining connections is safe.

**Testing**
- Added a test to `packages/mcp/test/oauth.test.ts`: it opens a spare
TCP connection to the callback port, completes a callback, and expects
`close()` to resolve within 2 s. It fails without the change and passes
with it.
- `npm run check` passes. The MCP OAuth tests and the coding-agent MCP
tests pass.
- Script reproduction: with a spare connection open, `close()` did not
resolve within 400 s before the change, and resolves in about 1 ms after
it.

Fixes #11311

Requested by @petrroll

Co-authored-by: triagent <triagent@localhost>
2026-11-05 23:51:53 +01:00
..
agent Anthropic message threads (#11545) 2026-11-03 14:07:57 +01:00
ai fix(ai,coding-agent): remove "(legacy)" marker from OpenAI Codex provider name 2026-11-05 22:51:36 +01:00
chord feat(p2): Chord v2 cleanup pass 2026-11-05 18:22:13 +00:00
codemode Add [Unreleased] section for next cycle 2026-11-02 11:38:21 +01:00
coding-agent fix(coding-agent): remove all extension overlays on /reload and session switch (#11853) 2026-11-05 23:30:54 +01:00
durable fix(durable): raise timeout of seeded SqliteStorage batch commit tests 2026-11-05 09:50:00 +01:00
env fix(env): kill what a process program left running when it exits 2026-11-03 14:17:21 +01:00
evals Release v1.5.0 2026-11-02 11:38:21 +01:00
mcp fix(mcp): close remaining connections when the OAuth callback server closes (#11855) 2026-11-05 23:51:53 +01:00
schema fix(schema): num no longer takes nan and infinity 2026-11-05 14:20:32 +01:00
telemetry feat(chord): telemetry from pages and workers stored by the server, who a span was for 2026-11-04 11:59:14 +00:00
tui fix(tui): prevent cursor marker leaks (#9441) 2026-11-04 11:26:48 +01:00