Skip to content

fix(mcp): serialize server start/stop so overlapping calls cannot leak a socket host (#1563) - #1692

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
fix/mcp-controller-start-stop-race
Oct 17, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
fix/mcp-controller-start-stop-race

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1563.

McpServerController.start() checked _host != null, then awaited the app version and host.start(), and only then assigned _host. Two overlapping calls (a toggle clicked twice, startIfEnabled racing the settings page, regenerateToken during a start) both passed the check and each built a host; the first was overwritten and left listening, and both wrote the endpoint file. stop() during a start closed nothing.

  • start, stop and regenerateToken now run one after another through a small chain (_serialized); a failed step does not break the chain for the next one.
  • regenerateToken is one step (stop and start with nothing in between), so another call cannot slip into the gap.

Tests: three overlapping start() calls produce one port and nothing listens on it after stop(); stop() queued behind a running start() leaves the server stopped with no endpoint file; start, stop, start works.

@github-actions github-actions Bot added bug Something isn't working stability Theme parser epic label: stability core Core library logic and services P2 Medium priority / Parity & Refactoring labels Oct 17, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 04714ac into dev Oct 17, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core Core library logic and services P2 Medium priority / Parity & Refactoring stability Theme parser epic label: stability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant