Telegram plugin MCP server crashes: missing error handler on bot.start()

Resolved 💬 3 comments Opened Mar 20, 2026 by KatsuJinCode Closed Mar 24, 2026

Description

The official Telegram channel plugin (claude-plugins-official/telegram/0.0.1) MCP server crashes repeatedly during sessions. The server dies within seconds of a successful reply tool call.

Root Cause

In server.ts, grammy's bot.start() (line 596) is called with void (fire-and-forget) and no .catch(). There is also no bot.catch() handler registered.

void bot.start({
  onStart: info => {
    botUsername = info.username
    process.stderr.write(`telegram channel: polling as @${info.username}\n`)
  },
})

If grammy's long-polling loop encounters any error (network hiccup, Telegram API rate limit, malformed response), the returned promise rejects. Since it was called with void, this becomes an unhandled promise rejection, which in Bun kills the process by default.

The MCP stdio transport and grammy's polling run concurrently. When the bot process dies, Claude Code reports "MCP server disconnected."

Steps to Reproduce

  1. Install the Telegram plugin and configure a bot token
  2. Start a Claude Code session with --channels plugin:telegram@claude-plugins-official
  3. Pair a Telegram account
  4. Send a message from Telegram, have Claude reply
  5. Server crashes within seconds. Telegram messages stop arriving.
  6. /mcp reconnect works but server crashes again quickly.

Suggested Fix

Add error handlers to prevent unhandled rejections from killing the process:

bot.catch(err => {
  process.stderr.write(`telegram channel: bot error: ${err.message ?? err}\n`)
})

bot.start({
  onStart: info => {
    botUsername = info.username
    process.stderr.write(`telegram channel: polling as @${info.username}\n`)
  },
}).catch(err => {
  process.stderr.write(`telegram channel: bot.start() failed: ${err.message ?? err}\n`)
})

process.on('unhandledRejection', err => {
  process.stderr.write(`telegram channel: unhandled rejection: ${err}\n`)
})

Environment

  • Claude Code: latest (2026-03-20)
  • Windows 11
  • Bun (bundled with plugin)
  • Telegram plugin: 0.0.1

Related Issues

  • #36427 - Telegram plugin MCP server disconnects despite active polling
  • #36615 - Telegram MCP server disconnects silently after idle period
  • #15904 - Feature request for auto-reconnect (closed)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗