Skip to content

fix(cli): route all pino logs to stderr to prevent stdout pollution in stdio transport#485

Open
sithu015 wants to merge 9 commits into
fdmtl:mainfrom
sithu015:fix-stdio-logging
Open

fix(cli): route all pino logs to stderr to prevent stdout pollution in stdio transport#485
sithu015 wants to merge 9 commits into
fdmtl:mainfrom
sithu015:fix-stdio-logging

Conversation

@sithu015

@sithu015 sithu015 commented Jun 6, 2026

Copy link
Copy Markdown

When using director http2stdio, the [director-http] connected successfully message is logged to stdout. This corrupts the JSON-RPC stream for MCP stdio clients (like Antigravity or Claude Desktop), causing errors like invalid character ':' after array element. This PR configures pino to output all logs to process.stderr to conform to the MCP specification.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the logger setup in packages/utilities/src/logger.ts by extracting the stream configuration into a standalone stream constant. Feedback suggests configuring pino.destination to write synchronously (sync: true) to ensure that log messages are not lost if the CLI process exits unexpectedly.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

// uncomment to hide json objects for any level other than trace or debug
// hideObject: !["trace", "debug"].includes(LOG_LEVEL.toLowerCase()),
})
: pino.destination(2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For CLI applications, using asynchronous logging can lead to lost log messages if the process exits unexpectedly or crashes before the internal buffer is flushed. Since this logger is used in a CLI context (e.g., MCP stdio transport), it is highly recommended to configure pino.destination to write synchronously by setting sync: true.

Suggested change
: pino.destination(2);
: pino.destination({ dest: 2, sync: true });

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.

1 participant