Skip to content

Fix stale WhatsApp Web version breaking all NOWEB sessions - #2193

Closed
bergpinheiro wants to merge 1 commit into
devlikeapro:devfrom
bergpinheiro:contrib/noweb-wa-version
Closed

Fix stale WhatsApp Web version breaking all NOWEB sessions#2193
bergpinheiro wants to merge 1 commit into
devlikeapro:devfrom
bergpinheiro:contrib/noweb-wa-version

Conversation

@bergpinheiro

@bergpinheiro bergpinheiro commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Fix stale WhatsApp Web version breaking all NOWEB sessions

Problem

@adiwajshing/baileys is pinned to fork-master-2026-04-28, which bakes in a fixed WhatsApp Web version ([2, 3000, 1035920091]). NOWEB never overrides it in getSocketConfig(), 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 STARTING and then move to FAILED. 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 new resolveWaVersion() helper:

  1. WAHA_NOWEB_WA_VERSION env var (e.g. "2,3000,1037641644") — for pinning a known-good version explicitly, no network call.
  2. Baileys' own 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.
  3. If both are unavailable, Baileys' own bundled default is used (unchanged behavior from today) — 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):

  • With no WAHA_NOWEB_WA_VERSION set: fetchLatestBaileysVersion() returned [2, 3000, 1043857760] (newer than the version people are currently sed-patching to), logged as Auto-detected latest WhatsApp Web version, session reached SCAN_QR_CODE and the version was correctly present in the outgoing registration node (appVersion.tertiary: 1043857760).
  • With WAHA_NOWEB_WA_VERSION=2,3000,1037641644 set: logged Using WhatsApp Web version from WAHA_NOWEB_WA_VERSION and that exact value was used, taking priority over auto-detection.
  • tsc --noEmit clean.

patron:PRO

…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).
@vd123D

vd123D commented Jul 29, 2026

Copy link
Copy Markdown

thanks. it worked.

@JrGrecco

Copy link
Copy Markdown

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.

@devlikepro

devlikepro commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

2026.7.2 - NOWEB - WAHA_NOWEB_WA_VERSION / WAHA_NOWEB_WA_VERSION_FORCE env variables to override WhatsApp Web version - NOWEB - #2193

patron:PRO

@devlikepro

devlikepro commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

👉 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 WAHA_NOWEB_WA_VERSION - no need to wait for a new WAHA release.

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 fetch-wa-version.js - it prints the latest WhatsApp Web version (like 2.3000.1234567890) to stdout, or prints nothing and exits with code 1 on failure, so WAHA falls back to the built-in version.

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 $$ - Docker Compose interpolates single ${...} itself, so the dollars must be doubled to reach the shell.

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:

  • If you set WAHA_NOWEB_WA_VERSION explicitly - it wins over the fetched one (thanks to :- in the wrapper).
  • The version is resolved once per container start - restart the container to pick up a newer version.
  • The fetch URL must be reachable from the container at startup - otherwise WAHA uses the built-in version.

patron:PRO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants