diff --git a/src/index.ts b/src/index.ts index 031216bdc..408b94a89 100644 --- a/src/index.ts +++ b/src/index.ts @@ -119,10 +119,10 @@ const isMain = if (isMain) { // Global error handlers to prevent silent crashes from unhandled rejections/exceptions. // These log the error and exit gracefully instead of crashing without trace. - process.on("unhandledRejection", (reason, promise) => { + process.on("unhandledRejection", (reason, _promise) => { console.error( "[warelay] Unhandled promise rejection:", - reason instanceof Error ? reason.stack ?? reason.message : reason, + reason instanceof Error ? (reason.stack ?? reason.message) : reason, ); process.exit(1); }); diff --git a/src/web/auto-reply.ts b/src/web/auto-reply.ts index 1ee1d7177..452fb0f91 100644 --- a/src/web/auto-reply.ts +++ b/src/web/auto-reply.ts @@ -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"; diff --git a/src/web/session.ts b/src/web/session.ts index 76e32599f..545291ebf 100644 --- a/src/web/session.ts +++ b/src/web/session.ts @@ -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"); });