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

@@ -54,7 +54,10 @@ async function connectSocket(phoneNumber?: string, isReconnect = false): Promise
process.exit(0);
}
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 };
});
const sock = makeWASocket({
version,
auth: {