Skip to content

fix: remove debug console.logs and use logger in library modules#613

Closed
ashsolei wants to merge 1 commit intoczlonkowski:mainfrom
ashsolei:fix/remove-debug-console-logs
Closed

fix: remove debug console.logs and use logger in library modules#613
ashsolei wants to merge 1 commit intoczlonkowski:mainfrom
ashsolei:fix/remove-debug-console-logs

Conversation

@ashsolei
Copy link

@ashsolei ashsolei commented Mar 1, 2026

Summary

Remove leftover debug console.log statements and replace bare console.log/warn/error calls with the project's logger utility in library modules.

Problem

  • config-validator.ts contained 3 leftover console.log('DEBUG: ...') statements inside a conditional block. In stdio mode, any direct console.log output corrupts the JSON-RPC transport stream.
  • docs-mapper.ts and node-loader.ts used bare console.log/warn/error for operational logging instead of the project's logger utility, which properly suppresses output in stdio mode via the MCP_MODE environment variable check.

Changes

File Change
src/services/config-validator.ts Removed 3 console.log('DEBUG: ...') statements and their containing conditional block
src/mappers/docs-mapper.ts Replaced 4 console.log calls with logger.warn/logger.debug
src/loaders/node-loader.ts Replaced 7 console.log/warn/error calls with logger.info/debug/warn/error

Testing

  • The logger utility is already well-tested and used throughout the codebase (18+ existing imports)
  • In stdio mode: logger suppresses all output, preventing JSON-RPC corruption
  • In HTTP mode: logger suppresses output during active MCP requests
  • In rebuild/validate scripts: logger outputs normally since MCP_MODE is not set

- Remove leftover DEBUG console.log statements from config-validator.ts
  that could corrupt JSON-RPC stream in stdio mode
- Replace bare console.log/warn/error in docs-mapper.ts with logger
  utility that respects MCP_MODE and suppresses output in stdio mode
- Replace bare console.log/warn/error in node-loader.ts with logger
  utility for consistent logging behavior
Copilot AI review requested due to automatic review settings March 1, 2026 02:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes leftover direct console.* output from library modules and routes operational/debug logging through the project logger utility to avoid corrupting stdio JSON-RPC streams (and to respect MCP_MODE-based suppression).

Changes:

  • Removed a debug-only console.log block from ConfigValidator’s Python return-format checks.
  • Replaced console.log usage in DocsMapper with logger.warn/logger.debug.
  • Replaced console.log/warn/error usage in N8nNodeLoader with logger.info/debug/warn/error.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/services/config-validator.ts Removes debug console.log statements that could interfere with stdio transports.
src/mappers/docs-mapper.ts Uses the shared logger for docs lookup logging (warn/debug).
src/loaders/node-loader.ts Uses the shared logger for package/node loading logs; updates error/warn/info/debug paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

results.push(...nodes);
} catch (error) {
console.error(`Failed to load ${pkg.name}:`, error);
logger.error(`Failed to load ${pkg.name}: ${error}`);
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

loadAllNodes() catch block interpolates the caught error into the message (${error}), which can degrade diagnostics (e.g., [object Object]) and drop stack traces. Since the project logger supports variadic args, pass the error as a separate argument (or log error instanceof Error ? error.message/stack : String(error)) so stack/metadata is preserved (see similar logger.error(msg, error) usage in src/http-server.ts).

Suggested change
logger.error(`Failed to load ${pkg.name}: ${error}`);
logger.error(`Failed to load ${pkg.name}`, error);

Copilot uses AI. Check for mistakes.
@ashsolei
Copy link
Author

ashsolei commented Mar 1, 2026

Closing — will maintain fixes in a private mirror instead. Thank you for the review.

@ashsolei ashsolei closed this Mar 1, 2026
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.

2 participants