mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
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> |
||
|---|---|---|
| .. | ||
| agent | ||
| ai | ||
| chord | ||
| codemode | ||
| coding-agent | ||
| durable | ||
| env | ||
| evals | ||
| mcp | ||
| schema | ||
| telemetry | ||
| tui | ||