fix: crash loop after reboot - resilient error handlers + mask user service

Root causes:
1. uncaughtException/unhandledRejection called gracefulShutdown() -> process.exit(0)
   Any minor error killed the entire bot. Changed to LOG ONLY (Hermes/OpenCode pattern).
2. User-level systemd service was running alongside system-level, fighting for port 3001.
   Masked user service permanently.
3. Fragile new Promise(() => {}) keepalive replaced with setInterval-based keepalive.
4. Syntax error in uncaughtException handler (literal newline in single-quoted string).

Tested: 5 rapid consecutive restarts all pass. Uptime stable.

Co-Authored-By: zcode <noreply@zcode.dev>
This commit is contained in:
admin
2026-05-06 16:51:12 +00:00
Unverified
parent 342cfb75bd
commit 994c5481bf
2 changed files with 32 additions and 8 deletions

View File

@@ -43,9 +43,20 @@ Changes:
6. **Full Hermes guardrail integration in tool execution loop** — beforeCall checks,
afterCall failure tracking, guidance appended to results
### 🐛 Fixed
- **Crash loop after reboot** — `uncaughtException` and `unhandledRejection` handlers were calling
`gracefulShutdown()` (which calls `process.exit(0)`), so ANY unhandled error killed the bot.
Changed to LOG ONLY (Hermes/OpenCode pattern) — only SIGINT/SIGTERM trigger clean shutdown.
- **Dual systemd service war** — User-level service (`~/.config/systemd/user/zcode.service`) was
running alongside system-level service, both fighting for port 3001. Masked the user service
permanently (`ln -sf /dev/null zcode.service`).
- **Fragile keepalive** — `await new Promise(() => {})` replaced with `setInterval`-based keepalive
that's robust against V8 optimization.
### 📄 Files Changed
- `src/bot/session-state.js` — Complete rewrite with Hermes guardrail controller (+200 lines)
- `src/bot/index.js` — Parallel tool execution, system prompt overhaul, bash tool guidance (+160 lines)
- `src/bot/index.js` — Parallel tool execution, system prompt overhaul, resilient error handlers (+160 lines)
- `src/bot/index.js` — Fixed syntax error in uncaughtException handler (literal newline in string)
- `CHANGELOG.md` — Updated with full v2.0.2 details
- `README.md` — Updated header with v2.0.2 summary