Heartbeat defaults and ws guard; format
This commit is contained in:
@@ -45,7 +45,7 @@ export type WebMonitorTuning = {
|
||||
const formatDuration = (ms: number) =>
|
||||
ms >= 1000 ? `${(ms / 1000).toFixed(2)}s` : `${ms}ms`;
|
||||
|
||||
const DEFAULT_REPLY_HEARTBEAT_MINUTES = 10;
|
||||
const DEFAULT_REPLY_HEARTBEAT_MINUTES = 30;
|
||||
export const HEARTBEAT_TOKEN = "HEARTBEAT_OK";
|
||||
export const HEARTBEAT_PROMPT = "HEARTBEAT ultrathink";
|
||||
|
||||
|
||||
@@ -90,7 +90,10 @@ export async function createWaSocket(printQr: boolean, verbose: boolean) {
|
||||
);
|
||||
|
||||
// Handle WebSocket-level errors to prevent unhandled exceptions from crashing the process
|
||||
if (sock.ws) {
|
||||
if (
|
||||
sock.ws &&
|
||||
typeof (sock.ws as unknown as { on?: unknown }).on === "function"
|
||||
) {
|
||||
sock.ws.on("error", (err: Error) => {
|
||||
sessionLogger.error({ error: String(err) }, "WebSocket error");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user