fix: add error handling and tests for WA Web version fetch

The fetchLatestWaWebVersion call added in #443 could crash the
connection flow if the HTTP fetch fails. Wrap with .catch() to log
and fall back to the default Baileys version.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gavriel Cohen
2026-02-24 07:04:33 +02:00
parent f4277b295a
commit 7631a5c686
3 changed files with 34 additions and 2 deletions

View File

@@ -56,7 +56,10 @@ export class WhatsAppChannel implements Channel {
const { state, saveCreds } = await useMultiFileAuthState(authDir);
const { version } = await fetchLatestWaWebVersion({});
const { version } = await fetchLatestWaWebVersion({}).catch((err) => {
logger.warn({ err }, 'Failed to fetch latest WA Web version, using default');
return { version: undefined };
});
this.sock = makeWASocket({
version,
auth: {