Skip to content

test: the MCP login test spawns the CLI only where it needs a process of its own - #984

Merged
kid7st merged 1 commit into
mainfrom
test/cli-mcp-fewer-spawns
Nov 8, 2026
Merged

kid7st merged 1 commit into
mainfrom
test/cli-mcp-fewer-spawns

Conversation

@kid7st

@kid7st kid7st commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

test/cli-mcp.test.ts's "MCP login gives a browser ticket, saves a grant/binding and disconnects without deleting the grant" timed out (45 s) on a loaded machine. The cause is the test's cost, not FastAgent.

Root cause

The test spawned the CLI 7 times, besides its --check polls and the two ticket steps' own processes, and each spawn is a cold start of the whole CLI. Timed per spawn in a Linux container (Node 26.13.0, 4 CPUs):

One spawn The test
Alone 0.24 s (0.65 s for a mcp login that starts a ticket) 7.8 s
In the shard 0.27 s 8 s
In the shard with 8 CPU-bound processes 2.4 to 8 s 33 to 43 s

The rest is the refused disconnect, which waits out BUSY_TIMEOUT_MS (5 s) for the storage the test holds, by design.

The fix

A process of its own only where the test needs one, as AGENTS.md asks of CLI tests:

  • the two mcp logins that start a ticket, whose step command is process.argv[1], which in process is not the CLI;
  • the disconnect refused while the test holds the storage, since a POSIX lock does not exclude its own process.

mcp list, the mcp login refused for having no --scopes, every --check, and the last disconnect now run in process. 3 spawns instead of 7 plus the polls.

Verification

Under the same load (the shard with 8 CPU-bound processes), the file took 24 s and 19 s, against 43 s and 33 s before. Alone it takes 8.7 to 10.5 s, a little more than before, since the worker now loads the CLI once. The whole suite passed on macOS and in the Linux container.

@kid7st
kid7st requested a review from Sukitly as a code owner November 8, 2026 18:52
@kid7st kid7st self-assigned this Nov 8, 2026
@github-actions github-actions Bot added the test Tests only label Nov 8, 2026
@kid7st
kid7st merged commit feceb2b into main Nov 8, 2026
12 checks passed
@kid7st
kid7st deleted the test/cli-mcp-fewer-spawns branch November 8, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant