Skip to content

Minor Contribution: improve error handling, logger portability, and server initialization patterns#2

Open
beer-to-code wants to merge 1 commit intonitrocloudofficial:mainfrom
beer-to-code:bug-quality-doc-issues
Open

Minor Contribution: improve error handling, logger portability, and server initialization patterns#2
beer-to-code wants to merge 1 commit intonitrocloudofficial:mainfrom
beer-to-code:bug-quality-doc-issues

Conversation

@beer-to-code
Copy link
Copy Markdown

@beer-to-code beer-to-code commented Apr 1, 2026

Description

Type of Change

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation update
  • refactor: Internal code change
  • test: Test-only changes
  • chore: Build, CI, or tooling changes

Related Issues

Changes Made

  • Fix missing break in resource content switch statement (server.ts)

The case 'json' branch was missing a break, causing fall-through to the default case. This silently overwrote JSON resource responses with double-serialized content.
Replace debug console.error with logger.debug (server.ts)

  • A console.error('[DEBUG] NitroStackServer.start()...') was running on every server start. Since MCP uses STDIO for JSON-RPC, any stderr output can interfere with the protocol. Replaced with this.logger.debug() to follow the project's own logging conventions.
    Use PromptNotFoundError instead of generic Error (server.ts)

  • The GetPromptRequestSchema handler threw new Error('Prompt not found: ...') while tools and resources already use their dedicated error classes (ToolNotFoundError, ResourceNotFoundError). Updated to use the existing PromptNotFoundError class from errors.ts for consistency.
    Remove console.error from Zod schema conversion (tool.ts)

  • The toJsonSchema() catch block used console.error, which breaks MCP's STDIO protocol. Changed to a silent fallback with an explanatory comment.
    Use os.devNull instead of hardcoded /dev/null (logger.ts)

  • The fallback logger transport used filename: '/dev/null', which doesn't exist on Windows. Replaced with Node.js built-in os.devNull for cross-platform compatibility.
    Bug Fixes (@nitrostack/cli)
    Fix non-existent createTool in generated scaffold code (init.ts)

  • The createProjectFromScratch fallback template imported createTool from @nitrostack/core, which doesn't exist in the public API. Updated to use new Tool({...}), which is the correct exported class.
    Fix incorrect website URL in generated README (init.ts)

  • Generated project READMEs linked to nitrostack.dev instead of nitrostack.ai

Testing

  • npm run lint
  • npm test
  • Manual testing performed (if applicable)

Screenshots / Recordings

Checklist

  • I have read and followed CONTRIBUTING.md
  • I have added/updated tests where appropriate
  • I have updated docs where appropriate
  • I have kept this PR focused and scoped
  • I have used conventional commits

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