mirror of
https://github.com/giancarloerra/socraticode.git
synced 2026-07-03 14:05:21 +02:00
fix(index): flush stderr before exit on Node 26+ guard
Per CodeRabbit review on #59: process.stderr.write() is async when stderr is piped (every MCP host captures stderr to surface server logs), so a bare `process.exit(1)` immediately after the write terminates synchronously without draining I/O — risking truncation of the compatibility warning that this guard exists to surface. Move the exit into the write callback so the message is guaranteed to flush before the process terminates. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-6
@@ -16,13 +16,17 @@
|
||||
// upper bound in package.json's `engines.node` and remove this check.
|
||||
const nodeMajor = Number.parseInt(process.versions.node.split(".")[0], 10);
|
||||
if (Number.isFinite(nodeMajor) && nodeMajor >= 26) {
|
||||
process.stderr.write(
|
||||
// Write-then-exit-in-callback: stderr writes are async when piped (every MCP host
|
||||
// captures stderr), and a bare `process.exit(1)` terminates the process synchronously
|
||||
// without draining I/O, risking truncation of this message.
|
||||
const msg =
|
||||
`socraticode: Node ${process.versions.node} is not supported.\n` +
|
||||
" @qdrant/js-client-rest is incompatible with the undici bundled in Node 26+.\n" +
|
||||
" Use Node 22.x (via nvm: `nvm install 22 && nvm use 22`, or `brew install node@22` on macOS).\n" +
|
||||
" See https://github.com/qdrant/qdrant-js/issues/134.\n",
|
||||
);
|
||||
process.exit(1);
|
||||
" @qdrant/js-client-rest is incompatible with the undici bundled in Node 26+.\n" +
|
||||
" Use Node 22.x (via nvm: `nvm install 22 && nvm use 22`, or `brew install node@22` on macOS).\n" +
|
||||
" See https://github.com/qdrant/qdrant-js/issues/134.\n";
|
||||
process.stderr.write(msg, () => {
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
|
||||
Reference in New Issue
Block a user