alvin-bot 4.25.0 → 4.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/bin/cli.js +13 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to Alvin Bot are documented here.
|
|
4
4
|
|
|
5
|
+
## [4.25.1] — 2026-05-13
|
|
6
|
+
|
|
7
|
+
### Fixed: `alvin-bot launchd install` now persists the PM2 cleanup
|
|
8
|
+
|
|
9
|
+
The launchd installer correctly called `pm2 delete alvin-bot` when migrating a previously-PM2-managed bot to launchd — but `pm2 delete` only mutates the live process list, **not** the persisted `~/.pm2/dump.pm2`. On the next login, PM2's startup script would call `pm2 resurrect`, see alvin-bot in the stale dump, and re-spawn it. The resurrected pm2-managed instance and the new launchd-managed instance then both polled Telegram with the same `BOT_TOKEN`, racking up `409 Conflict: terminated by other getUpdates request` errors until one of them crashed.
|
|
10
|
+
|
|
11
|
+
The fix adds `pm2 save --force` immediately after `pm2 delete`, so the dump file reflects reality. `--force` is needed because plain `pm2 save` refuses to persist an empty list with a warning. Other PM2-managed processes (e.g. unrelated projects in the user's PM2) are preserved correctly — the save only mutates entries for alvin-bot.
|
|
12
|
+
|
|
13
|
+
### How it surfaced
|
|
14
|
+
|
|
15
|
+
A maintainer's local Mac that had been running alvin-bot under PM2 *before* the v4.x migration to launchd hit `409 Conflict` errors out of nowhere — turns out PM2 had been silently resurrecting alvin-bot on every reboot for months (106,000+ restart counter), invocations without args printed help and exited, PM2 restarted it instantly, the cycle continued. Today the cycle accidentally aligned with a Telegram getUpdates call, causing the conflict. Cleanup steps:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pm2 delete polyseus # any other PM2 entries
|
|
19
|
+
pm2 save --force # empty dump
|
|
20
|
+
launchctl unload ~/Library/LaunchAgents/pm2.alvin_de.plist 2>/dev/null
|
|
21
|
+
rm -f ~/Library/LaunchAgents/pm2.alvin_de.plist
|
|
22
|
+
pm2 kill
|
|
23
|
+
npm uninstall -g pm2
|
|
24
|
+
rm -rf ~/.pm2
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
After this patch, future users migrating from PM2 to launchd via `alvin-bot launchd install` won't accumulate the stale-dump time bomb — the cleanup is persistent immediately.
|
|
28
|
+
|
|
29
|
+
### End-to-end verified on a real Apple Silicon Mac (.75)
|
|
30
|
+
|
|
31
|
+
1. Reproduced the broken pre-condition: install PM2, add alvin-bot to its dump via `pm2 start … && pm2 save`. `grep -c alvin-bot ~/.pm2/dump.pm2` → 7 hits.
|
|
32
|
+
2. Ran `alvin-bot launchd install` with the fix applied.
|
|
33
|
+
3. Verified `grep -c alvin-bot ~/.pm2/dump.pm2` → **0 hits**. PM2 live list is also empty.
|
|
34
|
+
|
|
35
|
+
The installer's output now ends with `🧹 Removed alvin-bot from pm2 and persisted (other pm2 projects left intact).` and includes a `💡 pm2 now has zero managed processes. You can remove it entirely:` hint when no other pm2 projects remain.
|
|
36
|
+
|
|
5
37
|
## [4.25.0] — 2026-05-13
|
|
6
38
|
|
|
7
39
|
### Auto-bootstrap media tools (yt-dlp + ffmpeg) on every setup and update
|
package/bin/cli.js
CHANGED
|
@@ -2743,7 +2743,19 @@ async function launchdInstall() {
|
|
|
2743
2743
|
if (pm2HadAlvinBot) {
|
|
2744
2744
|
try {
|
|
2745
2745
|
execSync("pm2 delete alvin-bot", { stdio: "pipe" });
|
|
2746
|
-
|
|
2746
|
+
// CRITICAL: `pm2 delete` only mutates the live process list; the
|
|
2747
|
+
// persisted dump (~/.pm2/dump.pm2) keeps a stale copy. Without
|
|
2748
|
+
// `pm2 save --force` here, the next time PM2 resurrects on
|
|
2749
|
+
// login it will re-spawn alvin-bot from the dump — fighting with
|
|
2750
|
+
// the new launchd-managed bot for the same BOT_TOKEN and racking
|
|
2751
|
+
// up Telegram getUpdates 409 conflicts (six-figure restart counts
|
|
2752
|
+
// in extreme cases). `--force` ensures the save runs even when
|
|
2753
|
+
// the resulting list is empty (default `pm2 save` warns and
|
|
2754
|
+
// skips the write on an empty list).
|
|
2755
|
+
try {
|
|
2756
|
+
execSync("pm2 save --force", { stdio: "pipe" });
|
|
2757
|
+
} catch { /* save failed — non-fatal, user has clean live list either way */ }
|
|
2758
|
+
console.log("🧹 Removed alvin-bot from pm2 and persisted (other pm2 projects left intact).");
|
|
2747
2759
|
} catch { /* already gone */ }
|
|
2748
2760
|
}
|
|
2749
2761
|
} catch { /* pm2 not installed — nothing to clean up */ }
|