8000 fix(mcp): accept clients while backend loads by lexfrei · Pull Request #319 · aenix-io/aeman · GitHub
[go: up one dir, main page]

Skip to content

fix(mcp): accept clients while backend loads - #319

Merged
kvaps merged 4 commits into
mainfrom
fix/mcp-startup-race
Nov 15, 2026
Merged

kvaps merged 4 commits into
mainfrom
fix/mcp-startup-race

Conversation

@lexfrei
@lexfrei lexfrei commented Nov 12, 2026
Copy link
Copy Markdown
Contributor

What

  • Start the HTTP listener before backend initialization and report starting until the real backend is ready.
  • Serve initialize and tools/list from a placeholder MCP server, then atomically swap in the real backend and ok health.
  • Make awaitHealthy wait for a ready status instead of accepting any non-unknown status.
  • Add backend initialization logs and startup/session tests.
  • Fix two existing lint findings.

Why

The listener used to open only after backend initialization, so clients could exhaust their retries with ECONNREFUSED and remain marked failed after the port appeared.

Validation

  • make test
  • make lint
  • make build
  • npm run typecheck && npm test — 1020 tests
  • Live restart: healthz moved from starting to ok; native get_board returned the board; git ls-remote succeeded.

Closes: #318

Bind HTTP before backend initialization so clients no longer hit ECONNREFUSED during startup. Report health as starting until the real backend takes over, and make awaitHealthy wait for it.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
Check the reload result before asserting that the board load started too early.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
Resolve the server and health callback per request so healthz changes from starting to ok after the real backend takes over. Cover the transition with a session and health assertion.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
Record data lock acquisition, repository loading and backend readiness to make startup latency diagnosable.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
@lexfrei
lexfrei marked this pull request as ready for review November 12, 2026 20:10
@kvaps
kvaps merged commit 9889240 into main Nov 15, 2026
2 checks passed
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.

MCP startup race: listener opens only after the board finishes loading

2 participants

0