claude-code - 💡(How to fix) Fix Telegram plugin: new sessions without --channels steal polling from active session [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#47753Fetched 2026-04-15 06:43:13
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
labeled ×2commented ×1

Fix Action

Fix / Workaround

Current workaround

Patching server.ts to change the PID lock logic from "kill old, start new" to "detect existing, exit if alive":

// Patched (exits if existing instance is alive): process.exit(0)

Code Example

// Original (kills existing instance):
process.kill(stale, 'SIGTERM')

// Patched (exits if existing instance is alive):
process.exit(0)
RAW_BUFFERClick to expand / collapse

Problem

When enabledPlugins has telegram@claude-plugins-official: true in ~/.claude/settings.json, every new Claude Code session spawns a Telegram plugin (bun process), even sessions started without the --channels flag.

The current PID lock mechanism in server.ts (v0.0.5) uses a "kill old, start new" approach — each new instance kills the previous one and takes over polling. This means:

  1. User starts Session A with --channels plugin:telegram@claude-plugins-official — Telegram works correctly
  2. User opens Session B (no --channels) for unrelated work — Session B's plugin kills Session A's bun process
  3. Session A loses Telegram connectivity entirely
  4. Session B receives Telegram messages but has no --channels context to handle them properly

This is disruptive for users who want a dedicated Telegram session running while working in other sessions.

Expected behavior

If a live Telegram plugin instance is already polling, new sessions should not replace it. The new instance should detect the existing one and exit gracefully, rather than killing the active poller.

Alternatively, sessions started without --channels should not spawn the Telegram plugin at all, even if enabledPlugins is true. The enabledPlugins flag could be treated as "available" rather than "always start", with --channels being the actual activation trigger.

Current workaround

Patching server.ts to change the PID lock logic from "kill old, start new" to "detect existing, exit if alive":

// Original (kills existing instance):
process.kill(stale, 'SIGTERM')

// Patched (exits if existing instance is alive):
process.exit(0)

This patch needs to be reapplied after every plugin update.

Environment

  • Claude Code CLI
  • Telegram plugin v0.0.5
  • ~/.claude/settings.json has "telegram@claude-plugins-official": true

Related

  • #39876 (zombie bun processes with v0.0.4)

extent analysis

TL;DR

To prevent new Claude Code sessions from killing existing Telegram plugin instances, modify the PID lock logic in server.ts to detect and exit if an instance is already alive.

Guidance

  • Identify the server.ts file responsible for the PID lock mechanism and locate the "kill old, start new" approach.
  • Replace the process.kill(stale, 'SIGTERM') line with process.exit(0) to implement the "detect existing, exit if alive" logic.
  • Consider treating the enabledPlugins flag as "available" rather than "always start" to prevent unnecessary plugin spawning.
  • Test the modified server.ts file to ensure the Telegram plugin instance is not killed when a new session is started without the --channels flag.

Example

// Patched server.ts
if (isInstanceAlive()) {
  process.exit(0); // Exit if existing instance is alive
} else {
  // Start new instance
}

Note: The isInstanceAlive() function is not implemented in the example, as it is not provided in the issue body.

Notes

The current workaround requires reapplying the patch after every plugin update, which may not be a sustainable solution. A more permanent fix would involve modifying the PID lock mechanism to handle multiple instances correctly.

Recommendation

Apply the workaround by modifying the server.ts file to implement the "detect existing, exit if alive" logic, as this is the most straightforward solution to prevent the killing of existing Telegram plugin instances.

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…

FAQ

Expected behavior

If a live Telegram plugin instance is already polling, new sessions should not replace it. The new instance should detect the existing one and exit gracefully, rather than killing the active poller.

Alternatively, sessions started without --channels should not spawn the Telegram plugin at all, even if enabledPlugins is true. The enabledPlugins flag could be treated as "available" rather than "always start", with --channels being the actual activation trigger.

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 - 💡(How to fix) Fix Telegram plugin: new sessions without --channels steal polling from active session [1 comments, 2 participants]