# Baileys session open but silent: the server_sync ack hang

> A Baileys session stays open, receives nothing for about 50 minutes, then closes on an unacked server_sync. Log signature, cause, watchdog and fix status.

Published 2026-11-23. Z-API Omni team.

A Baileys session that stays `open` for about 50 minutes with no inbound, then logs `stream errored out` on a `server_sync` ack, matches [issue #2917](https://github.com/WhiskeySockets/Baileys/issues/2917) (accessed 2026-11-23). A media download dropped mid-body during an app-state resync, `.pipe()` never surfaced the error, and the notification was never acked. The one-line fix is in open [PR #2923](https://github.com/WhiskeySockets/Baileys/pull/2923) (accessed 2026-11-23), and no Baileys release contains it as of 2026-11-23.

Webhook toggles, `notify` versus `append`, decryption failures and other causes are in [the general checklist for open sessions that receive nothing](/academy/articles/baileys-evolution-connected-no-messages-received/). Close codes such as 401 and 428 are in [Baileys disconnect codes, WAHA and Evolution API session errors](/academy/articles/waha-evolution-api-baileys-session-errors/).

## Confirm the bug from the log signature

Issue #2917 gives a timeline from one session in a multi-session process. Call the last normal inbound node T0. About 22 seconds later, the process logs an `uncaughtException`. The error is `TypeError: terminated`, caused by `SocketError: other side closed` (`UND_ERR_SOCKET`), "with only undici frames in the stack".

For the next 50 minutes or so, nothing comes in. No `connection.update` fires and the state stays `open`. The issue adds: "Every send hangs (`Sending message to …` logged, never completes). Other sessions in the same process are fine".

At about T0 + 50.5 minutes, Baileys logs this line at level 50 (error), quoted from the issue:

```json
{"level":50,"reasonNode":{"tag":"ack","attrs":{"class":"notification","type":"server_sync"}},"fullErrorNode":{"tag":"stream:error","attrs":{},"content":[{"tag":"ack","attrs":{"class":"notification","type":"server_sync"}}]},"msg":"stream errored out"}
```

Then Baileys reconnects, and per the issue "the withheld backlog arrives within seconds, with nothing lost".

### What close code to expect

The issue doesn't state the close code your `connection.update` handler receives. The following is a reading of the Baileys source on master at commit `bb0a87e`, not something the issue reports.

[`socket.ts` L988-L995](https://github.com/WhiskeySockets/Baileys/blob/bb0a87e0326ca8f882fe716c7ee42da362f73fc0/src/Socket/socket.ts#L988-L995) (accessed 2026-11-23) logs `stream errored out` and ends the socket with `Stream Errored (${reason})`. [`getErrorCodeFromStreamError`](https://github.com/WhiskeySockets/Baileys/blob/bb0a87e0326ca8f882fe716c7ee42da362f73fc0/src/Utils/generics.ts#L356-L377) (accessed 2026-11-23) maps only `conflict` and otherwise falls back to `badSession`. The #2917 `stream:error` carries no `code` attribute. So the close should read `Stream Errored (ack)` with `statusCode` 500. The rc.9 build maps it the same way.

For reconnect logic, a handler that clears auth on 500 turns a stall that heals itself into a forced QR re-pair. Reconnect with the same auth instead.

### Make the signature visible

The stream error is logged at error level. A logger set to `fatal` hides it. The config in [Baileys #2908](https://github.com/WhiskeySockets/Baileys/issues/2908) (accessed 2026-11-23) uses `level: 'fatal'`, for example. In Evolution API, set `LOG_BAILEYS` to `error` or a more verbose level.

Register a process-level `uncaughtException` logger too, so `TypeError: terminated` with `UND_ERR_SOCKET` gets recorded. A comment on [PR #2716](https://github.com/WhiskeySockets/Baileys/pull/2716) (accessed 2026-11-23) shows the same error on rc13 with Node 22, where the process exited with code 1. Without a handler, this bug can crash the process instead of hanging it.

## Why the session goes deaf

The chain runs through four places in the source, all at commit `bb0a87e` and accessed 2026-11-23. A `server_sync` notification arrives, and [`messages-recv.ts` L1067-L1073](https://github.com/WhiskeySockets/Baileys/blob/bb0a87e0326ca8f882fe716c7ee42da362f73fc0/src/Socket/messages-recv.ts#L1067-L1073) awaits `resyncAppState([name], false)` inside notification processing.

The resync reads external app-state blobs. [`chat-utils.ts` L406-L413](https://github.com/WhiskeySockets/Baileys/blob/bb0a87e0326ca8f882fe716c7ee42da362f73fc0/src/Utils/chat-utils.ts#L406-L413) calls `downloadContentFromMessage` with type `'md-app-state'`, then loops with `for await (const chunk of stream)`. If the stream never ends or errors, that loop waits forever.

The stream comes from [`messages-media.ts` L657](https://github.com/WhiskeySockets/Baileys/blob/bb0a87e0326ca8f882fe716c7ee42da362f73fc0/src/Utils/messages-media.ts#L657), which still reads `return fetched.pipe(output, { end: true })`. When the HTTP body drops mid-download, `.pipe()` doesn't forward the error to `output`. The error escapes as an `uncaughtException`, and `output` never ends.

The ack sits in a `finally` block after that work. In [`messages-recv.ts` L1552-L1583](https://github.com/WhiskeySockets/Baileys/blob/bb0a87e0326ca8f882fe716c7ee42da362f73fc0/src/Socket/messages-recv.ts#L1552-L1583), `processNotification` runs inside `notificationMutex`, then `sendMessageAck(node)` runs. A hung `processNotification` means no ack, and the mutex stays held.

The issue explains the recovery: "The new socket has a fresh mutex, which is why it 'heals itself' after ~50 min." It also notes that the affected session was the busiest one, with "about 10k contacts and 2.6k chats, so it has the largest app state".

### Which versions block inbound messages

How much the hang blocks depends on the version. Older builds put messages and notifications behind one mutex. From rc10 on, Baileys splits them, as [`chats.ts` L119-L129](https://github.com/WhiskeySockets/Baileys/blob/bb0a87e0326ca8f882fe716c7ee42da362f73fc0/src/Socket/chats.ts#L119-L129) shows on master (accessed 2026-11-23). This table comes from the compiled npm packages and the master source:

| Version | One mutex for messages and notifications | `fetched.pipe(...)` present |
| --- | --- | --- |
| 6.7.24 (`legacy` tag) | Yes | Yes |
| 7.0.0-rc.9 (pinned by Evolution API 2.3.7) | Yes | Yes |
| 7.0.0-rc10 to rc14 | No, split into `messageMutex` and `notificationMutex` | Yes |
| master `bb0a87e` | No | Yes |

On 6.7.x and rc.9, a hung `server_sync` also stops inbound messages inside Baileys. On rc10 and later, it stops later notifications and the `server_sync` ack. Whether WhatsApp then withholds messages is open. The issue says so directly: "Our data can't tell whether WhatsApp also withholds other stanzas while that ack is pending."

## Two bugs that look similar from a dashboard

[Baileys #2913](https://github.com/WhiskeySockets/Baileys/issues/2913) (accessed 2026-11-23) leaves the socket stuck in `connecting` when the WebSocket upgrade gets a non-101 response. No `close` or `error` event fires, and `connectTimeoutMs` doesn't help. The reporter's client "logged the connect step and then nothing for four days, until a manual restart." Fix [PR #2922](https://github.com/WhiskeySockets/Baileys/pull/2922) is open (accessed 2026-11-23). The difference from #2917: the state is `connecting`, not `open`, and sends can't work at all.

The second one is an unacked `<status>` stanza, addressed by open [Baileys PR #2883](https://github.com/WhiskeySockets/Baileys/pull/2883) (accessed 2026-11-23). [Evolution API PR #2788](https://github.com/evolution-foundation/evolution-api/pull/2788), merged on 2026-11-23 and shipped in [Evolution API 2.3.8](https://github.com/evolution-foundation/evolution-api/releases/tag/2.3.8) (accessed 2026-11-24), describes the same shape on Evolution 2.3.7. Its body reads: "After roughly 50 minutes the server ends the stream (`stream errored out`, `ack class=status`, 3–9 times per hour)." It adds that the reconnected session "stops receiving messages or gets them hours late." The reason node in your log tells the two apart: `status` or `server_sync`.

Plain closes behave differently. A 401 or 428 produces a `connection.update` with `connection: 'close'` right away, so the session is never silently open. The [session errors article](/academy/articles/waha-evolution-api-baileys-session-errors/) covers what to do with each.

## Catch it with a watchdog on inbound silence

Connection state can't catch this bug, because the state stays `open`. Watch the time since the last inbound message per session instead, and alert relative to that session's own traffic. This watchdog was type-checked with TypeScript 5.6.3 in strict mode against `baileys@7.0.0-rc14`. Baileys 7 is ESM only, hence the `.js` extension in the usage example's local import.

```typescript
import type { WASocket } from 'baileys'

export type SilenceAlert = {
  sessionId: string
  silentForMs: number // time since the last inbound messages.upsert
  thresholdMs: number // what counts as abnormal for this session
  lastInboundAt: number
}

type Options = {
  sessionId: string
  onSilence: (alert: SilenceAlert) => void
  checkEveryMs?: number // default 60 s
  floorMs?: number // never alert below this, default 15 min
  multiplier?: number // threshold = multiplier x this session's usual longest gap
  minSamples?: number // gaps to learn before alerting
}

export function watchInbound(sock: WASocket, opts: Options) {
  const checkEveryMs = opts.checkEveryMs ?? 60_000
  const floorMs = opts.floorMs ?? 15 * 60_000
  const multiplier = opts.multiplier ?? 3
  const minSamples = opts.minSamples ?? 20

  const gaps: number[] = [] // recent gaps between inbound events, ms
  let lastInboundAt = Date.now()
  let isOpen = false
  let alerted = false

  // 95th percentile of recent gaps: this session's "usually quiet for at most" value
  const usualGap = () => {
    const sorted = [...gaps].sort((a, b) => a - b)
    return sorted[Math.floor(sorted.length * 0.95)] ?? 0
  }

  sock.ev.on('connection.update', ({ connection }) => {
    if (connection === 'open') {
      isOpen = true
      lastInboundAt = Date.now() // don't count time spent disconnected
      alerted = false
    } else if (connection === 'close') {
      isOpen = false
    }
  })

  sock.ev.on('messages.upsert', ({ messages }) => {
    // any message from someone else proves inbound still flows, notify or append
    if (!messages.some(m => !m.key.fromMe)) return
    const now = Date.now()
    gaps.push(now - lastInboundAt)
    if (gaps.length > 500) gaps.shift()
    lastInboundAt = now
    alerted = false
  })

  const timer = setInterval(() => {
    if (!isOpen || alerted || gaps.length < minSamples) return
    const thresholdMs = Math.max(floorMs, multiplier * usualGap())
    const silentForMs = Date.now() - lastInboundAt
    if (silentForMs < thresholdMs) return
    alerted = true // once per silence
    opts.onSilence({ sessionId: opts.sessionId, silentForMs, thresholdMs, lastInboundAt })
  }, checkEveryMs)
  timer.unref()

  return () => clearInterval(timer)
}
```

Wire it to each socket:

```typescript
import makeWASocket, { useMultiFileAuthState } from 'baileys'
import { watchInbound } from './inbound-watchdog.js'

const { state } = await useMultiFileAuthState('auth/SESSION_ID')
const sock = makeWASocket({ auth: state })

const stop = watchInbound(sock, {
  sessionId: 'SESSION_ID',
  onSilence: ({ sessionId, silentForMs, thresholdMs, lastInboundAt }) => {
    console.warn('inbound silent', {
      sessionId,
      silentMin: Math.round(silentForMs / 60_000),
      thresholdMin: Math.round(thresholdMs / 60_000),
      lastInboundAt: new Date(lastInboundAt).toISOString()
    })
    // save the logs first, then decide whether to force a reconnect:
    // void sock.end(new Error('inbound watchdog'))
  }
})
void stop
```

Call `watchInbound` again after every reconnect, because each reconnect creates a new `sock`. `useMultiFileAuthState` keeps the example short. The [Baileys v7 article](/academy/articles/baileys-v7-lts-2027-keep-session-current/) carries Baileys' warning against it in production.

The `sock.end` line is commented out on purpose. Ending the socket brings the fresh mutex #2917 describes, and it throws away the state you'd want to inspect.

The threshold uses the 95th percentile of recent gaps and doesn't model time of day. A session that's busy by day and quiet at night will alert at night unless you raise `floorMs`.

Evolution API users can't hook `sock.ev` directly. Apply the same logic to the time since the last `MESSAGES_UPSERT` webhook for each connected number.

## Fix it today

### Running Baileys directly

The fix replaces `.pipe()` with `pipeline`, so a dropped download rejects instead of hanging. Issue #2917 gives it as a diff:

```diff
- return fetched.pipe(output, { end: true })
+ return pipeline(fetched, output, () => {})
```

The reporter writes: "We run exactly this as a patch on rc.9 in production". PR #2923 makes the same change, adds `pipeline` to the existing `stream` import and returns `output` after the call. It also adds a test. Its author reports that "`yarn test` passes (29 suites, 413 tests). I did not run the e2e suite."

To apply it before a release, patch the compiled file `node_modules/baileys/lib/Utils/messages-media.js` (line 494 in rc.9, 515 in rc14). Evolution API 2.3.8 ships its own Baileys patch through `patch-package` (`patches/baileys+7.0.0-rc.9.patch`), from [PR #2788](https://github.com/evolution-foundation/evolution-api/pull/2788) (accessed 2026-11-24), so the pattern has precedent. Regenerate the patch for every Baileys version you install. You can also install the PR #2923 branch to test it. No maintainer has reviewed it.

Upgrading to rc14 doesn't fix #2917, because rc14 still has `.pipe()`. It does split the mutexes, so inbound messages no longer queue behind the hung resync inside Baileys. Whether that's enough depends on the unknown above. Upgrading also moves you out of the range of a critical advisory covered in the [Baileys v7 article](/academy/articles/baileys-v7-lts-2027-keep-session-current/).

The issue also suggests two hardening steps: "ack the notification before resyncing" and "bound `resyncAppState` with a timeout". Neither appears in any Baileys PR found as of 2026-11-23.

### Running Evolution API 2.3.7 or 2.3.8

Evolution API 2.3.7 pins Baileys exactly, with no caret: [`package.json` at tag 2.3.7](https://github.com/evolution-foundation/evolution-api/blob/2.3.7/package.json) (accessed 2026-11-23) has `"baileys": "7.0.0-rc.9"`. The tag has no `patch-package` step. The `main` branch, the `2.4.0-rc2` pre-release and the `release/2.3.8` branch also use rc.9. The `develop` branch moves to rc13 and adds `patch-package`.

Evolution API 2.3.8 was released on 2026-11-23. It still pins `"baileys": "7.0.0-rc.9"` and adds `patch-package` as a `postinstall` step. Its patch changes only `lib/Socket/messages-recv.js`, to ack top-level `<status>` stanzas. It does not touch `messages-media.js`, so the #2917 `pipeline` fix is not included.

Build your own image with a `patch-package` patch for `baileys+7.0.0-rc.9`, following the pattern in PR #2788. Upgrading to 2.3.8 fixes the `<status>` ack stall only. For #2917, add the `pipeline` change to the same `patches/baileys+7.0.0-rc.9.patch` and rebuild the image. The #2917 reporter runs both the `pipeline` patch and the `<status>` ack patch on rc.9.

A container restart or a re-pair gives you a fresh socket, which only resets the clock. If the cause is #2917, the next dropped download during a resync can stall the session again.

### Caveat: your Evolution stall may be something else

Two Evolution reports describe the dashboard symptom, and nothing public ties them to #2917. In [#2789](https://github.com/evolution-foundation/evolution-api/issues/2789) (accessed 2026-11-23), one commenter saw messages reach the webhook almost seven hours late. In [#2790](https://github.com/evolution-foundation/evolution-api/issues/2790) (accessed 2026-11-23), a container restart recovered the session twice, then didn't. Another comment there mentions a decryption failure fixed only by a new QR scan.

One commenter posted the same claim in both threads: updating `CONFIG_SESSION_PHONE_VERSION` fixes the problem. Nobody has confirmed it works, so treat it as unverified. Whether Baileys #2908 shares the #2917 cause is also unconfirmed. Its reporter is on rc14 and logs at `fatal`, so the #2917 signature wouldn't show.

## Fix status on 2026-11-24

| Item | State on 2026-11-24 |
| --- | --- |
| [Baileys #2917](https://github.com/WhiskeySockets/Baileys/issues/2917) | Open, no maintainer reply |
| [Baileys PR #2923](https://github.com/WhiskeySockets/Baileys/pull/2923) | Open, not merged. Automated bot reviews only, no maintainer review |
| [Baileys PR #2716](https://github.com/WhiskeySockets/Baileys/pull/2716) | Closed by the stale bot, not merged |
| [Baileys PR #2838](https://github.com/WhiskeySockets/Baileys/pull/2838) | Closed by the stale bot, not merged |
| [Baileys PR #2815](https://github.com/WhiskeySockets/Baileys/pull/2815) | Closed by its author as a duplicate of #2716 |
| [Baileys #2913](https://github.com/WhiskeySockets/Baileys/issues/2913) and [PR #2922](https://github.com/WhiskeySockets/Baileys/pull/2922) | Both open |
| [Baileys PR #2883](https://github.com/WhiskeySockets/Baileys/pull/2883) | Open |
| [Evolution API PR #2788](https://github.com/evolution-foundation/evolution-api/pull/2788) | Merged 2026-11-23, released in 2.3.8 |

All links accessed 2026-11-24. The latest Baileys release is still `7.0.0-rc14`, from 2026-07-29, so no Baileys release contains either fix.

WhatsApp's Help Center page [About unofficial WhatsApp apps](https://faq.whatsapp.com/1217634902127718) (accessed 2026-11-23) sets the context for any library built on WhatsApp Web. It says: "Unofficial WhatsApp apps and websites are versions of WhatsApp developed by third-parties without WhatsApp's approval." It adds: "Using these apps or linking your WhatsApp account to unofficial versions of WhatsApp violates our Terms of Service."

The page also says: "Connecting a third-party agent through WhatsApp's supported agent feature is different from using an unofficial WhatsApp app or website." Its examples are "GB WhatsApp, FM WhatsApp, TeleMessage, TM WhatsApp, and others". It doesn't name Baileys or any library.

*Z-API Omni team*
