Telegram channel plugin: MCP server crashes on broken stdio pipe (unhandled promise rejection)
Bug Description
The Telegram channel plugin (plugin:telegram@claude-plugins-official) crashes during runtime when the MCP stdio pipe encounters any disruption (e.g., context compression, session management). This makes the Telegram channel unreliable for sustained use.
Root Cause
Three fire-and-forget promises in server.ts lack error handling:
1. mcp.notification() called with void (line ~580)
void mcp.notification({
method: 'notifications/claude/channel',
params: { content: text, meta: { ... } },
})
If the stdio transport to Claude Code breaks, this promise rejects. Since it's called with void, it becomes an unhandled promise rejection → process crash.
2. No bot.catch() handler
Grammy's Bot instance has no error handler registered. Any error in message handlers or polling propagates as an unhandled exception.
3. bot.start() called with void (line ~596)
void bot.start({ onStart: info => { ... } })
Same fire-and-forget pattern. If polling fails fatally, the rejection is unhandled.
Observed Behavior
- User sends a message from Telegram
- Bot receives it, shows "typing..." indicator ✓
- Bot attempts
mcp.notification()to forward to Claude session - If stdio pipe is in a bad state → unhandled rejection → bun process crashes
- Claude Code reports: "MCP server disconnected"
- All Telegram tools (
reply,react,edit_message) become unavailable - No way to reconnect without restarting the entire Claude session
Suggested Fix
// 1. Global safety net
process.on('unhandledRejection', err => {
process.stderr.write(`telegram channel: unhandled rejection: ${err}\n`)
})
// 2. Grammy error handler
bot.catch(err => {
process.stderr.write(`telegram channel: bot error: ${err.message ?? err}\n`)
})
// 3. Catch notification failures instead of void
mcp.notification({ ... }).catch(err => {
process.stderr.write(`telegram channel: notification failed: ${err}\n`)
})
// 4. Catch bot.start() failures
bot.start({ ... }).catch(err => {
process.stderr.write(`telegram channel: bot.start() failed: ${err}\n`)
})
Environment
- Claude Code CLI (macOS, Darwin 25.2.0)
- Bun 1.3.11
- Plugin:
telegram@0.0.1 - grammy: 1.41.1
- @modelcontextprotocol/sdk: 1.27.1
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗