fix(telegram): replace SIGTERM dedup with atomic lock + follower mode#1374
Closed
thewusman2025 wants to merge 1 commit intoanthropics:mainfrom
Closed
fix(telegram): replace SIGTERM dedup with atomic lock + follower mode#1374thewusman2025 wants to merge 1 commit intoanthropics:mainfrom
thewusman2025 wants to merge 1 commit intoanthropics:mainfrom
Conversation
The v0.0.5 bot.pid mechanism SIGTERMs any existing poller on startup, which kills the MCP pipe of legitimate concurrent sessions (anthropics#1360, anthropics#1363). Replace with an atomic exclusive-create lock file (O_CREAT|O_EXCL). If the lock holder is alive, the new instance yields into follower mode — outbound tools (reply, edit, react, download) remain active via bot.api, only polling is skipped. Dead holders are reclaimed normally. Three changes: - acquirePollLock() using fs.openSync('wx') instead of SIGTERM - Follower mode: skip bot.start(), call getMe() for outbound tools - Lock cleanup on shutdown (only if owned by this process) Fixes anthropics#1360, anthropics#1363. Related: anthropics#1344. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks for your interest! This repo only accepts contributions from Anthropic team members. If you'd like to submit a plugin to the marketplace, please submit your plugin here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bot.pidSIGTERM mechanism with an atomic exclusive-create lock file (O_CREAT|O_EXCLviafs.openSync('wx')). When a second instance starts and the lock holder is alive, it yields into follower mode instead of killing the existing poller — preserving the active MCP pipe.bot.start()(no polling), callsgetMe()for bot identity, keeps all outbound MCP tools active (reply,edit_message,react,download_attachment) since they usebot.api.*which doesn't require a polling loop.kill(pid, 0)throws), the stale lock is removed and the new instance becomes leader.poll.lockif owned by this process, matching v0.0.5's existing pattern.Problem
The v0.0.5
bot.pidmechanism (#1349) SIGTERMs any existing poller on startup. This was intended to clear zombies, but it kills the MCP pipe of legitimate concurrent sessions — cron-fired sessions kill the interactive session's poller (#1360), and the dual-load bug (#1344) causes the second load to kill the first (#1363).What changed
bot.pid, SIGTERM holder, claim slotopenSync('wx')— fails if lock existsTest plan
replyworksFixes #1360, #1363. Related: #1344.
🤖 Generated with Claude Code