claude-code - ✅(Solved) Fix Telegram channel plugin: notifications not injected into conversation [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46356Fetched 2026-04-11 06:22:27
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1

Error Message

Messages are silently dropped between the MCP server notification and the conversation. No error is visible to the user.

PR fix notes

PR #1377: fix(telegram): retry polling on all errors, not just 409 Conflict

Description (problem / solution / changelog)

Summary

The poll-loop startup in server.ts only retries 409 Conflict errors. Any other transient error (connection timeout, TLS reset, DNS hiccup) causes bot.start() to reject, the catch block to return, and polling to stop permanently. The plugin process stays alive because MCP stdin keeps it running — so outbound tools (reply, react, edit_message) continue to work while the bot is completely deaf to inbound Telegram messages.

This is one of the root causes behind the widespread "outbound works, inbound doesn't" reports across 65+ open issues.

Root cause analysis

The vulnerable code path (lines 988–1035):

} catch (err) {
  // ...
  if (err instanceof GrammyError && err.error_code === 409) {
    // retry with backoff
    continue
  }
  // ...
  process.stderr.write(`telegram channel: polling failed: ${err}\n`)
  return  // ← ANY non-409 error exits the loop permanently
}

After return, the async IIFE exits. The process stays alive because the MCP server's stdin reader keeps the event loop running. Outbound tool calls work (they create fresh HTTP requests), but grammy's poll loop is dead — no getUpdates calls, no inbound messages.

Evidence (strace on a stalled plugin)

$ timeout 10 strace -p <plugin_pid> -e trace=network,write,read -f
strace: Process <pid> attached
strace: Process <pid> detached
(zero output — zero syscalls in 10 seconds)

FD inspection during the stall:

$ for fd in /proc/<pid>/fd/*; do echo "$(basename $fd) -> $(readlink $fd)"; done
0 -> socket:[...]    # MCP stdin (alive)
1 -> socket:[...]    # MCP stdout (alive)
2 -> socket:[...]    # stderr
3 -> /dev/urandom
4 -> anon_inode:[eventpoll]
# ... all internal FDs, ZERO TCP sockets to api.telegram.org

After applying this fix, the plugin maintained 2 ESTABLISHED TCP connections to 149.154.166.110:443 for 3+ hours and recovered from transient errors automatically.

What this PR changes

  • Catch ALL errors in the poll-loop, not just 409 — retry with exponential backoff (up to 15s)
  • Track consecutive 409s separately so the "another poller is active" give-up logic (8 attempts) is preserved
  • Reset counters on successful bot.start() via the onStart callback
  • Log all retry errors with the error message so operators can see what's happening

What this PR does NOT fix

There is a second, separate bug in Claude Code itself: after ~2–3 hours, Claude Code's internal handler for notifications/claude/channel events stops surfacing inbound messages, even when the plugin is alive and actively polling (confirmed via strace showing active write syscalls and ESTABLISHED TCP sockets). This is tracked in anthropics/claude-code#46744 and others. This PR fixes the plugin-side crash; the Claude Code notification handler degradation is a separate issue.

Related issues

  • anthropics/claude-code#46744 — Telegram plugin: inbound messages not delivered to conversation
  • anthropics/claude-code#46016 — Telegram plugin: inbound messages not delivered to session
  • anthropics/claude-code#46356 — Telegram channel plugin: notifications not injected into conversation
  • anthropics/claude-plugins-official#870 — Inbound Telegram DMs silently dropped
  • anthropics/claude-plugins-official#1345 — inbound messages consumed by server but never rendered as channel tag

Test plan

  • Verified in Docker container (Debian bookworm, Bun 1.x) for 3+ hours
  • Confirmed via strace that plugin maintains TCP connections after fix
  • 409 Conflict handling still works (consecutive409 counter, 8-attempt limit)
  • Graceful shutdown (bot.stop() / "Aborted delay") still exits cleanly
  • Needs testing on macOS and Windows native

🤖 Generated with Claude Code

Changed files

  • external_plugins/telegram/server.ts (modified, +29/-19)

Code Example

claude --channels plugin:telegram@claude-plugins-official --debug
RAW_BUFFERClick to expand / collapse

Bug Description

When using the Telegram channel plugin (plugin:telegram@claude-plugins-official v0.0.4), incoming Telegram messages are not being injected into the Claude Code conversation, even though all upstream steps are working correctly.

Steps to Reproduce

  1. Start Claude Code with the Telegram channel:
    claude --channels plugin:telegram@claude-plugins-official --debug
  2. Send a message from Telegram to the bot
  3. Observe that the message never appears in the Claude Code conversation

Diagnostic Results

Verified the following pipeline:

StepStatus
1. Telegram → Bot polling✅ Working
2. Bot → notifications/claude/channel✅ Notification sent
3. Claude Code → conversation injection❌ Message not injected
  • Only one Claude Code session is running (confirmed via ps aux)
  • The Telegram plugin bun process is running normally
  • Outbound messages (Claude → Telegram via reply tool) work fine
  • No other Claude Desktop or CLI instances are competing for the connection

Environment

  • Claude Code: 2.1.100
  • Telegram plugin: 0.0.4
  • OS: macOS 26.3 (Build 25D125)
  • Bun: 1.3.12
  • Node: v25.6.0

Expected Behavior

Incoming Telegram messages should appear in the conversation as <channel source="telegram" ...> blocks, allowing Claude to read and respond to them.

Actual Behavior

Messages are silently dropped between the MCP server notification and the conversation. No error is visible to the user.

extent analysis

TL;DR

The issue is likely due to a problem with the conversation injection step in the Claude Code, and verifying the plugin configuration and debugging the claude --channels command may help resolve the issue.

Guidance

  • Verify that the Telegram plugin is correctly configured and enabled in the Claude Code settings.
  • Run the claude --channels command with the --verbose flag to increase logging and potentially identify the issue: claude --channels plugin:telegram@claude-plugins-official --debug --verbose.
  • Check the Claude Code documentation to ensure that the Telegram plugin is compatible with the current version of Claude Code (2.1.100).
  • Investigate the MCP server notification handling to see if there are any issues with the notification being sent or received.

Example

No code snippet is provided as the issue does not imply a specific code-related fix.

Notes

The issue may be related to a compatibility problem between the Telegram plugin and the current version of Claude Code, or a configuration issue with the plugin. Further debugging and investigation are needed to determine the root cause.

Recommendation

Apply workaround: Try updating the Telegram plugin to a newer version if available, or try using a different channel plugin to see if the issue is specific to the Telegram plugin.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - ✅(Solved) Fix Telegram channel plugin: notifications not injected into conversation [1 pull requests, 1 comments, 2 participants]