diff --git a/src/channels/whatsapp.ts b/src/channels/whatsapp.ts index 9b05f96..02d814e 100644 --- a/src/channels/whatsapp.ts +++ b/src/channels/whatsapp.ts @@ -80,7 +80,7 @@ export class WhatsAppChannel implements Channel { if (connection === 'close') { this.connected = false; - const reason = (lastDisconnect?.error as any)?.output?.statusCode; + const reason = (lastDisconnect?.error as { output?: { statusCode?: number } })?.output?.statusCode; const shouldReconnect = reason !== DisconnectReason.loggedOut; logger.info({ reason, shouldReconnect, queuedMessages: this.outgoingQueue.length }, 'Connection closed'); @@ -103,7 +103,9 @@ export class WhatsAppChannel implements Channel { logger.info('Connected to WhatsApp'); // Announce availability so WhatsApp relays subsequent presence updates (typing indicators) - this.sock.sendPresenceUpdate('available').catch(() => {}); + this.sock.sendPresenceUpdate('available').catch((err) => { + logger.warn({ err }, 'Failed to send presence update'); + }); // Build LID to phone mapping from auth state for self-chat translation if (this.sock.user) { diff --git a/src/env.ts b/src/env.ts index 2bd86f0..988b59e 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,5 +1,6 @@ import fs from 'fs'; import path from 'path'; +import { logger } from './logger.js'; /** * Parse the .env file and return values for the requested keys. @@ -12,7 +13,8 @@ export function readEnvFile(keys: string[]): Record { let content: string; try { content = fs.readFileSync(envFile, 'utf-8'); - } catch { + } catch (err) { + logger.debug({ err }, '.env file not found, using defaults'); return {}; }