anthropics / anthropics/claude-plugins-official

telegram plugin: missing appendFileSync import silently kills inbound polling

オープン 初心者向け
#3,801 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
36.3k
フォーク
4.1k
平均マージ
2日 14時間
マージ済み PR(30日)
539

説明

## Summary

Telegram plugin's `server.ts` never receives inbound Telegram messages after process starts, even though MCP server connects fine and outbound sending (reply/send tools) works. `bot.pid` exists, bun process stays alive, but `getUpdates` polling never starts. Telegram's `getWebhookInfo` shows `pending_update_count` growing forever, never draining.

## Root cause

`server.ts` line ~1006, inside `bot.start()` retry loop (added to handle transient network errors):

```ts
appendFileSync('/tmp/bun-notify.log', `[${new Date().toISOString()}] bot.start attempt ${attempt}\n`)
```

`appendFileSync` not imported. Top-level `fs` import (line ~22) only pulls in:

```ts
import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync, renameSync, realpathSync, chmodSync } from 'fs'
```

Other call sites in same file use dynamic `import('fs').then(({appendFileSync}) => ...)` instead — this one doesn't.

Retry loop is fire-and-forget `void (async () => {...})()`, no top-level try/catch around this line. `ReferenceError: appendFileSync is not defined` becomes unhandled promise rejection. Caught only by generic `process.on('unhandledRejection', ...)` logger (stderr, easy to miss — MCP stdio piped). Loop exits before ever calling `bot.start()`.

Result: process looks healthy (MCP tools registered, `bot.pid` written, outbound sends work) but deaf to all inbound messages — silently, permanently — until someone notices and manually patches/restarts.

## Fix

Add `appendFileSync` to `fs` import:

```ts
import { readFileSync, writeFileSync, appendFileSync, mkdirSync, readdirSync, rmSync, statSync, renameSync, realpathSync, chmodSync } from 'fs'
```

Verified locally (patched `server.ts` in plugin cache, restarted): `bot.start()` now runs, `onStart` fires, `pending_update_count` drains, inbound messages route to Claude Code as expected.

## Repro

1. Install/run telegram plugin, let session with `--channels plugin:telegram@claude-plugins-official` come up.
2. Confirm `bot.pid` written and `/mcp` shows `plugin:telegram:telegram · connected`.
3. Send DM to bot.
4. Check `curl https://api.telegram.org/bot/getWebhookInfo` — `pending_update_count` climbs, never drops. No message reaches Claude session.

## Suggested follow-up

Failure mode is silent (no crash, no visible error, tools still register). Worth either:
- wrapping retry loop body in try/catch that surfaces hard failure, or
- adding startup self-check confirming `bot.start()` actually completed `onStart` within N seconds before considering channel "ready."

---Diagnosed by Claude (Sonnet 5), running as Claude Code. telegram plugin version 0.0.6, Claude Code v2.1.202.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Open the Telegram plugin's server.ts and inspect the top-level fs import near line 22 and the bot.start() retry loop near line 1006. Reproduce with the listed Telegram polling steps, then verify that bot.start() runs, onStart fires, and pending_update_count drains after the import is corrected.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
backend
issue の種類
バグ
難易度
1/5
見積もり時間
1時間未満
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
90/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。