opencode-telegram-bot
opencode-telegram-bot copied to clipboard
[Bug]: status falsely deletes live daemon state due to second-resolution process start comparison
What is broken?
opencode-telegram status can falsely classify a live daemon as stale, delete
run/bot-service.json, and report stopped while the process is still alive.
After that opencode-telegram stop is a no-op and opencode-telegram start can
spawn a second daemon.
Steps to reproduce
- Start the daemon with
opencode-telegram start --daemon --mode installed. - The state file stores a millisecond timestamp, e.g.:
"startedAt": "2026-11-11T03:20:39.620Z". ps -o lstart= -p <pid>returns the process start rounded to the next second:Wed Nov 11 03:20:40 2026.- Run
opencode-telegram status. - Status logs a false stale-daemon warning, removes
run/bot-service.json, and reportsstopped. - The process is still alive and is still the bot:
/usr/bin/node /usr/local/share/npm-global/bin/opencode-telegram start --mode installed. opencode-telegram stopnow reports "not running", whilestartmay create a duplicate daemon.
OS
Linux
Additional context (optional)
Environment:
@grinev/opencode-telegram-bot0.27.0- Node.js 24.22.2
- Linux x86_64
- Installed globally via npm, started with
--daemon --mode installed
Likely regression from PR #190: https://github.com/grinev/opencode-telegram-bot/pull/190
getBotServiceStatus() in src/runtime/service/manager.ts does:
const processCreationTime = await getProcessCreationTime(service.pid);
const storedStartedAtMs = Date.parse(service.startedAt);
if (
processCreationTime &&
!Number.isNaN(storedStartedAtMs) &&
processCreationTime.getTime() > storedStartedAtMs
) {
// mark stale and delete bot-service.json
}
Observed log:
[2026-11-11T21:42:29.924Z] [WARN] [Manager] Stale daemon state detected: PID=1606 exists but was created at 2026-11-11T03:20:40.000Z (daemon started at 2026-11-11T03:20:39.620Z). The original process died and the PID was reused.
Removed stale daemon state file.
Service status: stopped
fixed in https://github.com/grinev/opencode-telegram-bot/releases/tag/v0.28.0