Fix stale WhatsApp Web version breaking all NOWEB sessions - #2193
Fix stale WhatsApp Web version breaking all NOWEB sessions#2193bergpinheiro wants to merge 1 commit into
Conversation
…undled default The version baked into the pinned Baileys fork goes stale whenever WhatsApp bumps the version it accepts server-side, breaking every NOWEB session at once (STARTING -> FAILED). Resolve it in priority order: WAHA_NOWEB_WA_VERSION env var, then Baileys' own fetchLatestBaileysVersion() (cached per process, falls back to the bundled default on failure).
|
thanks. it worked. |
|
fetchLatestBaileysVersion() fetches from the Baileys GitHub repo (Defaults/index.ts), not from WhatsApp, so it returns whatever version the Baileys maintainers last committed. That's exactly the value that went stale and caused #2191, so auto-detection would return the broken version and the fix would appear not to work. fetchLatestWaWebVersion() reads client_revision from https://web.whatsapp.com/sw.js, which is what WhatsApp actually serves. Measured during the outage: our NOWEB was announcing 2.3000.1035920091, web.whatsapp.com/sw.js returned 1044017588. Patching the compiled JS with the latter brought all sessions back immediately, including previously paired ones, with no re-scan. Suggestion: try fetchLatestWaWebVersion() first and keep fetchLatestBaileysVersion() as the fallback, so there are two network sources before the bundled default. |
|
👉 https://waha.devlike.pro/docs/engines/noweb/#configuration 🌀 Auto-update WhatsApp Web Version You can resolve the latest WhatsApp Web version right before WAHA starts and pass it via It’s safe by design: WAHA uses the fetched version only if it’s higher than the built-in one, so a failed or stale fetch simply falls back to the built-in version. Save the script as Two versions of the script - fetching the version from WhatsApp Web directly (recommended) or from the latest Baileys sources on GitHub: WhatsApp Web // Prints the latest WhatsApp Web version (e.g. "2.3000.1234567890") to stdout.
// Prints nothing and exits 1 on failure, so WAHA falls back to the built-in version.
const HEADERS = {
'sec-fetch-site': 'none',
'user-agent':
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
};
async function main() {
const response = await fetch('https://web.whatsapp.com/sw.js', {
headers: HEADERS,
signal: AbortSignal.timeout(15_000),
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = await response.text();
const match = text.match(/\\?"client_revision\\?":\s*(\d+)/);
if (!match) {
throw new Error('client_revision not found in sw.js');
}
console.log(`2.3000.${match[1]}`);
}
main().catch((err) => {
console.error(`Could not fetch the latest WhatsApp Web version: ${err}`);
process.exit(1);
});Baileys // Prints the WhatsApp Web version pinned in the latest Baileys sources (e.g. "2.3000.1234567890") to stdout.
// Prints nothing and exits 1 on failure, so WAHA falls back to the built-in version.
const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/index.ts';
async function main() {
const response = await fetch(URL, { signal: AbortSignal.timeout(15_000) });
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = await response.text();
const match = text.match(/const version = \[(\d+),\s*(\d+),\s*(\d+)\]/);
if (!match) {
throw new Error('version not found in Defaults/index.ts');
}
console.log(`${match[1]}.${match[2]}.${match[3]}`);
}
main().catch((err) => {
console.error(`Could not fetch the latest WhatsApp Web version: ${err}`);
process.exit(1);
});Option 1 - docker-compose (no image build) Mount the script and wrap the original entrypoint - the version is resolved once per container start: services:
waha:
image: devlikeapro/waha
volumes:
- ./fetch-wa-version.js:/fetch-wa-version.js:ro
entrypoint:
- /usr/bin/tini
- --
- /bin/sh
- -c
- |
export WAHA_NOWEB_WA_VERSION="$${WAHA_NOWEB_WA_VERSION:-$$(node /fetch-wa-version.js)}"
exec /entrypoint.sh👉 Note the Option 2 - your own image on top of WAHA FROM devlikeapro/waha:latest
COPY fetch-wa-version.js /fetch-wa-version.js
# Original ENTRYPOINT ["/usr/bin/tini", "--"] is inherited - only the CMD changes
CMD ["/bin/sh", "-c", "export WAHA_NOWEB_WA_VERSION=\"${WAHA_NOWEB_WA_VERSION:-$(node /fetch-wa-version.js)}\"; exec /entrypoint.sh"]A few things to keep in mind:
|
Fix stale WhatsApp Web version breaking all NOWEB sessions
Problem
@adiwajshing/baileysis pinned tofork-master-2026-04-28, which bakes in a fixed WhatsApp Web version ([2, 3000, 1035920091]). NOWEB never overrides it ingetSocketConfig(), so every connection uses that hardcoded value.When WhatsApp bumps the version it accepts server-side, every NOWEB session breaks at once — connections get stuck in
STARTINGand then move toFAILED. This just happened again and is affecting multiple installations, e.g. #2191.Today the only workaround is patching the compiled JS by hand inside the container (
sed -i '/markOnlineOnConnect: .../a\ version: [...]' dist/core/engines/noweb/session.noweb.core.js), which most users can't do and which has to be redone by hand every time WhatsApp bumps again.Fix
getSocketConfig()now resolves the WhatsApp Web version in priority order, in a newresolveWaVersion()helper:WAHA_NOWEB_WA_VERSIONenv var (e.g."2,3000,1037641644") — for pinning a known-good version explicitly, no network call.fetchLatestBaileysVersion()— auto-detects the current version, cached in memory per process (1h TTL) so many sessions starting together don't all hit the network at once.fetchLatestBaileysVersion()already falls back to it internally on network failure, so this never throws.This is additive/backward compatible: if nothing is configured and the network fetch fails, behavior is identical to before the change.
Testing
Verified locally against a real WhatsApp account (NOWEB engine, Docker):
WAHA_NOWEB_WA_VERSIONset:fetchLatestBaileysVersion()returned[2, 3000, 1043857760](newer than the version people are currently sed-patching to), logged asAuto-detected latest WhatsApp Web version, session reachedSCAN_QR_CODEand the version was correctly present in the outgoing registration node (appVersion.tertiary: 1043857760).WAHA_NOWEB_WA_VERSION=2,3000,1037641644set: loggedUsing WhatsApp Web version from WAHA_NOWEB_WA_VERSIONand that exact value was used, taking priority over auto-detection.tsc --noEmitclean.