fix: log heartbeat failure reasons

This commit is contained in:
Peter Steinberger
2025-12-26 08:34:42 +00:00
parent f734801da1
commit 112908886c
2 changed files with 6 additions and 3 deletions

View File

@@ -18,6 +18,7 @@
### Fixes
- Heartbeat replies now strip repeated `HEARTBEAT_OK` tails to avoid accidental “OK OK” spam.
- Heartbeat failure logs now include the error reason instead of `[object Object]`.
- Duration strings now accept `h` (hours) where durations are parsed (e.g., heartbeat intervals).
- WhatsApp send now preserves existing JIDs (including group `@g.us`) instead of coercing to `@s.whatsapp.net`. (Thanks @arun-8687.)
- Telegram/WhatsApp: reply context stays in `Body`/`ReplyTo*`, but outbound replies no longer thread to the original message. (Thanks @joshp123 for the PR and follow-up question.)

View File

@@ -11,6 +11,7 @@ import {
saveSessionStore,
type SessionEntry,
} from "../config/sessions.js";
import { formatErrorMessage } from "../infra/errors.js";
import { createSubsystemLogger } from "../logging.js";
import { getQueueSize } from "../process/command-queue.js";
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
@@ -367,13 +368,14 @@ export async function runHeartbeatOnce(opts: {
});
return { status: "ran", durationMs: Date.now() - startedAt };
} catch (err) {
const reason = formatErrorMessage(err);
emitHeartbeatEvent({
status: "failed",
reason: String(err),
reason,
durationMs: Date.now() - startedAt,
});
log.error("heartbeat failed", { error: String(err) });
return { status: "failed", reason: String(err) };
log.error(`heartbeat failed: ${reason}`, { error: reason });
return { status: "failed", reason };
}
}