Skip to content

[Bug] LSP discovery debug logs spam the terminal on startup (NODE_ENV-driven) #606

Description

@will-lamerton

Summary

Startup floods the terminal with debug logs (Loading real Pino dependencies, Command not in PATH, Server verification failed, etc.) when the user's environment has NODE_ENV=development. nanocoder is a TUI and should not key its console verbosity off ambient NODE_ENV. Reported in #605.

Root cause

  • NODE_ENV is the master switch for log verbosity. In development, the default level becomes debug and dev-only log lines are emitted (source/utils/logging/logger-provider.ts:119,148; source/utils/logging/config.ts:42).
  • The real Pino logger writes file-only (source/utils/logging/pino-logger.ts:37-43), but it loads asynchronously. Until it resolves, logging goes through the fallback logger, which writes to console (logger-provider.ts:255-264). The first getLogger() caches this fallback and it is never replaced after Pino loads (logger-provider.ts:144-145), so the console path stays live for the whole session.
  • LSP auto-discovery probes ~17 language servers via where <cmd> and logs each "not installed" result at debug with the full Error object (source/lsp/server-discovery.ts:257,286).

Proposed changes

  • Decouple console verbosity from NODE_ENV. Make the fallback console logger silent unless an explicit opt-in (NANOCODER_LOG_LEVEL, or a --debug flag) is set. Files: source/utils/logging/logger-provider.ts (getDefaultLogLevel), source/utils/logging/config.ts (getEnvironmentConfig).
  • Quiet expected LSP discovery results: log "command not found" at trace without the full Error dump, or aggregate into a single "N of M language servers found" line (source/lsp/server-discovery.ts).
  • Clean up the dead/misleading process.stdout.fd production destination and contradictory comments in config.ts.

Acceptance criteria

  • NODE_ENV=development nanocoder in a dir with no language servers installed shows a clean TUI; the same detail still lands in the log file.
  • NANOCODER_LOG_LEVEL=debug nanocoder still surfaces debug output (explicit opt-in preserved).
  • pnpm run test:ava source/utils/logging/pino-logger.spec.ts and pnpm run test:types pass.

Workaround

Unset NODE_ENV (or set it to production) before launching.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingclean uphelp wantedExtra attention is needed

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions