Skip to content

fix: improve graceful shutdown handling for MCP server#91

Merged
CoderGamester merged 1 commit intoCoderGamester:mainfrom
PhilipLudington:fix/graceful-shutdown
Dec 30, 2025
Merged

fix: improve graceful shutdown handling for MCP server#91
CoderGamester merged 1 commit intoCoderGamester:mainfrom
PhilipLudington:fix/graceful-shutdown

Conversation

@PhilipLudington
Copy link
Copy Markdown
Contributor

  • Add isShuttingDown flag to prevent double-shutdown race conditions
  • Add SIGTERM and SIGHUP signal handlers in addition to SIGINT
  • Add stdin close/end/error handlers for when MCP client disconnects
  • Handle EPIPE/EOF errors gracefully as expected disconnection
  • Call server.close() during shutdown for proper cleanup
  • Exit with code 1 for actual errors vs code 0 for clean shutdown

🤖 Generated with Claude Code

- Add isShuttingDown flag to prevent double-shutdown race conditions
- Add SIGTERM and SIGHUP signal handlers in addition to SIGINT
- Add stdin close/end/error handlers for when MCP client disconnects
- Handle EPIPE/EOF errors gracefully as expected disconnection
- Call server.close() during shutdown for proper cleanup
- Exit with code 1 for actual errors vs code 0 for clean shutdown

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 30, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@PhilipLudington PhilipLudington marked this pull request as ready for review December 30, 2025 01:01
Copy link
Copy Markdown
Owner

@CoderGamester CoderGamester left a comment

Choose a reason for hiding this comment

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

Good improvement for a clean shutdown

@CoderGamester CoderGamester merged commit 54706d6 into CoderGamester:main Dec 30, 2025
1 check passed
@PhilipLudington PhilipLudington deleted the fix/graceful-shutdown branch December 31, 2025 01:32
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