Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

mcp: a server that stops quotes its last log line reliably (the stdout reader waited no time for the stderr reader, so the reason was sometimes missing - the flaky test_a_server_that_fails_is_left_out)

Niko12217dc1fae80be9
diff --git a/serve/mcp.py b/serve/mcp.py
index 610eac61b..4586e2c19 100644
--- a/serve/mcp.py
+++ b/serve/mcp.py
@@ -108,8 +108,9 @@ class StdioTransport:
except OSError as e:
raise McpError(f"could not start {command!r}: {e}") from None
contain(self.proc) # ends with the server, however it ends (Windows)
+ self._err_reader = threading.Thread(target=self._read_stderr, daemon=True)
+ self._err_reader.start()
threading.Thread(target=self._read, daemon=True).start()
- threading.Thread(target=self._read_stderr, daemon=True).start()
def alive(self) -> bool:
return self.proc is not None and self.proc.poll() is None and not getattr(self, "ended", False)
@@ -144,6 +145,9 @@ class StdioTransport:
if isinstance(m, dict):
self._dispatch(m)
self.ended = True
+ # the server's last log line says why it stopped: let the stderr reader take it first (the pipe closes with
+ # the process), or the error raced it and said only "the server stopped"
+ self._err_reader.join(1.0)
code = self.proc.poll()
err = McpError(f"the server stopped{f' (exit code {code})' if code is not None else ''}{self._tail()}")
with self.lock: