You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mcp): McpServerController.start/stop race creates a second socket host and leaks the first #1563
McpServerController.start() (lib/core/mcp/mcp_server_controller.dart:102-124) checks _host != null first, then awaits _version() and host.start(), and assigns _host only after that. Two overlapping calls (startIfEnabled + setEnabled(true), repeated toggle, regenerateToken) create two McpSocketHosts: the first is leaked (never stopped), both write the same endpoint file and the token in the file may not belong to the host that is tracked.
stop() during an in-flight start() sees _host == null, does nothing, and the server comes up afterwards while the setting says disabled.
host.changes.listen is also never cancelled.
Expected
Serialize start / stop (single in-flight future or a lock) and assign _host before the first await.
Cancel the changes subscription on stop.
Test: concurrent start() x2 yields one host; stop() during start() ends stopped.
Fixed on dev by 04714ac: fix(mcp): serialize McpServerController start/stop so overlapping calls cannot leak a socket host (#1563) (#16. It reaches main with the next dev to main merge (closed after checking the code and its tests).
Activity
fix(mcp): serialize McpServerController start/stop so overlapping cal…
ZhuchkaTriplesix commentedon Oct 25, 2026
Fixed on dev by 04714ac: fix(mcp): serialize McpServerController start/stop so overlapping calls cannot leak a socket host (#1563) (#16. It reaches main with the next dev to main merge (closed after checking the code and its tests).