claude-code - 💡(How to fix) Fix Telegram plugin dies mid-session: stdin pipe closed after MCP respawn [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#53348Fetched 2026-04-26 05:18:05
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1

Fix Action

Workaround

Session restart (/exit + relaunch) reliably brings the plugin back. No in-session recovery is possible since the harness controls the stdio pipe.

Code Example

[2026-04-25T17:02:10.398Z] telegram plugin: file logging enabled
[2026-04-25T17:02:10.403Z] telegram channel: replacing stale poller pid=96441
[2026-04-25T17:02:10.403Z] telegram channel: SIGTERM received
[2026-04-25T17:02:10.403Z] telegram channel: shutting down (reason: signal/explicit)
[2026-04-25T17:02:10.408Z] telegram channel: MCP connected (pid=99541, ppid=99539)
[2026-04-25T17:02:10.549Z] telegram channel: bot.stop() resolved, exiting
[2026-04-25T17:02:10.872Z] telegram channel: polling as @miles_fam_ai_bot
[2026-04-25T17:02:11.484Z] telegram channel: stdin end event
[2026-04-25T17:02:11.484Z] telegram channel: shutting down (reason: signal/explicit)
[2026-04-25T17:02:11.486Z] telegram channel: stdin close event
[2026-04-25T17:02:13.487Z] telegram channel: force-exit timeout

---

[2026-04-25T10:00:05]Same: replace stale -> new MCP -> stdin end at 10:01:51
[2026-04-24T10:00:03]Same: replace stale -> new MCP -> stdin end at 10:01:14
RAW_BUFFERClick to expand / collapse

Bug

The Telegram MCP plugin (marketplace: telegram@claude-plugins-official) reliably dies mid-session when Claude Code respawns the plugin process. The new instance connects and starts polling, but the parent closes the stdin pipe within ~1 second, killing the MCP transport.

Reproduction

This happens consistently across sessions — not on every session, but frequently enough to be a daily occurrence. The pattern:

  1. Plugin is running fine for hours
  2. Claude Code respawns the plugin (possibly during context compaction or internal MCP reconnect)
  3. New plugin instance starts, MCP connects, polling begins
  4. stdin pipe closes ~1 second later
  5. Plugin shuts down — no new instance is spawned to replace it
  6. Plugin stays dead for the rest of the session

Diagnostic Log

From a stderr intercept added to server.ts (logged to ~/.local/state/miles-bot/telegram-plugin.log):

[2026-04-25T17:02:10.398Z] telegram plugin: file logging enabled
[2026-04-25T17:02:10.403Z] telegram channel: replacing stale poller pid=96441
[2026-04-25T17:02:10.403Z] telegram channel: SIGTERM received
[2026-04-25T17:02:10.403Z] telegram channel: shutting down (reason: signal/explicit)
[2026-04-25T17:02:10.408Z] telegram channel: MCP connected (pid=99541, ppid=99539)
[2026-04-25T17:02:10.549Z] telegram channel: bot.stop() resolved, exiting
[2026-04-25T17:02:10.872Z] telegram channel: polling as @miles_fam_ai_bot
[2026-04-25T17:02:11.484Z] telegram channel: stdin end event
[2026-04-25T17:02:11.484Z] telegram channel: shutting down (reason: signal/explicit)
[2026-04-25T17:02:11.486Z] telegram channel: stdin close event
[2026-04-25T17:02:13.487Z] telegram channel: force-exit timeout

Key observation: the old instance (pid 96441) and new instance (pid 99541) overlap — SIGTERM is sent to the old one, but the old one's bot.stop() resolves after the new one starts polling. The new instance's stdin closes 1 second after it connects.

This pattern repeats across multiple days:

[2026-04-25T10:00:05] — Same: replace stale -> new MCP -> stdin end at 10:01:51
[2026-04-24T10:00:03] — Same: replace stale -> new MCP -> stdin end at 10:01:14

The 10:00 AM instances are killed by a separate scheduled Claude session (a Desktop task that runs a gmail sweep) — that session's exit appears to kill the Telegram plugin in the main session too. The 17:02 instance today was mid-session with no external trigger.

Environment

  • macOS 15.4 (Darwin 25.4.0)
  • Claude Code CLI (latest as of 2026-04-25)
  • Plugin: telegram@claude-plugins-official v0.0.6
  • Runtime: Bun
  • Transport: stdio

Expected Behavior

When Claude Code respawns a plugin, the new instance's stdin pipe should remain open for the lifetime of the session. If the respawn fails, Claude Code should retry or surface the failure to the user.

Workaround

Session restart (/exit + relaunch) reliably brings the plugin back. No in-session recovery is possible since the harness controls the stdio pipe.

extent analysis

TL;DR

The Telegram MCP plugin dies mid-session due to the stdin pipe closing shortly after a new instance connects, and a potential fix involves modifying the plugin or Claude Code to handle the stdin pipe closure or implement a retry mechanism.

Guidance

  • Investigate the Claude Code respawn mechanism to determine why the stdin pipe is being closed after a new plugin instance connects.
  • Review the Telegram plugin code to see if there's a way to handle the stdin pipe closure or implement a retry mechanism when the pipe is closed unexpectedly.
  • Consider adding logging or debugging statements to the plugin and Claude Code to gain more insight into the sequence of events leading up to the stdin pipe closure.
  • Examine the scheduled Desktop task that runs a Gmail sweep to determine if it's related to the stdin pipe closure.

Example

No code snippet is provided as the issue lacks specific technical details about the plugin or Claude Code implementation.

Notes

The root cause of the issue is unclear, and more investigation is needed to determine the exact reason for the stdin pipe closure. The provided workaround of restarting the session may not be a long-term solution.

Recommendation

Apply a workaround, such as implementing a retry mechanism in the plugin or modifying the Claude Code respawn mechanism to handle the stdin pipe closure, as the issue is not fully understood and a direct fix is not available.

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