Skip to content

fix(whatsapp): expose Baileys socket timing#73580

Merged
velvet-shark merged 2 commits intomainfrom
codex/whatsapp-baileys-socket-timing
Apr 28, 2026
Merged

fix(whatsapp): expose Baileys socket timing#73580
velvet-shark merged 2 commits intomainfrom
codex/whatsapp-baileys-socket-timing

Conversation

@velvet-shark
Copy link
Copy Markdown
Member

Summary

  • make WhatsApp Web socket timing explicit at the Baileys makeWASocket boundary
  • expose web.whatsapp.keepAliveIntervalMs, connectTimeoutMs, and defaultQueryTimeoutMs in config/schema/docs
  • pass resolved timing through monitor, login, QR login, reconnect-after-515, and direct inbox socket paths

Root cause

Baileys emits 408 Request Time-out Connection was lost when its own inbound-frame watchdog exceeds the keepalive window. OpenClaw previously did not pass or expose Baileys socket timing, so every socket was stuck on upstream defaults. Local logs also showed separate 499 OpenClaw watchdog restarts; this PR keeps that watchdog separate and fixes the Baileys-level 408 path at socket creation.

Fixes #56365.
Related: #58481, #72735.

Verification

  • pnpm test extensions/whatsapp/src/socket-timing.test.ts extensions/whatsapp/src/session.test.ts extensions/whatsapp/src/connection-controller.test.ts src/config/schema.test.ts src/config/schema.help.quality.test.ts
  • pnpm config:schema:check
  • pnpm config:docs:check
  • pnpm docs:check-mdx
  • pnpm exec oxfmt --check --threads=1 extensions/whatsapp/src/socket-timing.ts extensions/whatsapp/src/socket-timing.test.ts extensions/whatsapp/src/session.ts extensions/whatsapp/src/session.test.ts extensions/whatsapp/src/connection-controller.ts extensions/whatsapp/src/auto-reply/monitor.ts extensions/whatsapp/src/auto-reply/types.ts extensions/whatsapp/src/inbound/monitor.ts extensions/whatsapp/src/login.ts extensions/whatsapp/src/login-qr.ts src/config/types.base.ts src/config/zod-schema.ts src/config/schema.help.ts src/config/schema.labels.ts src/config/schema.help.quality.test.ts src/config/schema.test.ts
  • git diff --check

Note: Testbox changed gate was not run because blacksmith is not installed/on PATH in this environment. pnpm changed:lanes --json selects core + WhatsApp extension lanes for this change.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Apr 28, 2026
@velvet-shark velvet-shark self-assigned this Apr 28, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented Apr 28, 2026

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

Keep this PR open. It is maintainer-authored (MEMBER) and carries the protected maintainer label, so it needs explicit maintainer handling. Current main also does not yet expose or pass the proposed WhatsApp/Baileys socket timing settings, so the PR is still an active implementation candidate for #56365 rather than obsolete cleanup.

Best possible solution:

Keep the PR open for maintainer review. The likely best path is to validate the Baileys timing contract, review the chosen OpenClaw defaults and web.whatsapp.* config shape, run the targeted WhatsApp/config checks plus the appropriate changed gate, then land or request revisions. After merge, #56365 can be closed for the timing portion or narrowed to any remaining non-timing socket-config needs.

What I checked:

  • Protected maintainer item: The provided GitHub context lists the PR author association as MEMBER and labels include maintainer; this workflow must not auto-close maintainer-owned or protected-label items. (189c91eae6e1)
  • Current socket boundary lacks timing passthrough: createWaSocket currently accepts only authDir and onQr, then calls makeWASocket without keepAliveIntervalMs, connectTimeoutMs, or defaultQueryTimeoutMs. (extensions/whatsapp/src/session.ts:126, 189c91eae6e1)
  • Current config schema lacks web.whatsapp: WebConfig and the runtime zod schema currently expose enabled, heartbeatSeconds, and reconnect, but no web.whatsapp timing object. (src/config/types.base.ts:293, 189c91eae6e1)
  • Reconnect/login paths do not preserve timing today: Current reconnect-after-515 and normal controller socket creation call createWaSocket with only authDir plus QR callback where relevant, so even a future call-site option would not currently flow through these paths. (extensions/whatsapp/src/connection-controller.ts:197, 189c91eae6e1)
  • Docs do not yet document the proposed settings: The WhatsApp docs mention the reconnect watchdog and existing operations keys, but not web.whatsapp.* socket timing tuning on current main. Public docs: docs/channels/whatsapp.md. (docs/channels/whatsapp.md:148, 189c91eae6e1)
  • Dependency contract supports the intended options: The pinned WhatsApp dependency is @whiskeysockets/baileys@7.0.0-rc.9; upstream SocketConfig includes connectTimeoutMs, defaultQueryTimeoutMs, and keepAliveIntervalMs, and upstream defaults are 20000, 60000, and 30000 respectively. (extensions/whatsapp/package.json:7, 189c91eae6e1)

Remaining risk / open question:

Codex review notes: model gpt-5.5, reasoning high; reviewed against 189c91eae6e1.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR exposes three Baileys socket timing parameters (keepAliveIntervalMs, connectTimeoutMs, defaultQueryTimeoutMs) through a new socket-timing.ts module and threads them into every WhatsApp Web socket creation path — monitor, login, QR login, reconnect, and direct inbox. The new config fields are wired through the type system, Zod schema, generated schema, labels, help text, and documentation.

Confidence Score: 5/5

This PR is safe to merge — well-structured, fully tested, and no correctness issues found.

All socket creation paths receive explicitly resolved timing values via resolveWhatsAppSocketTiming, which validates inputs with positiveInteger. The Zod schema, TypeScript types, generated schema, labels, help text, docs, and changelog are all consistently updated. Tests cover the default, config-override, and call-site-override cases. No logic bugs, data-loss paths, or security concerns identified.

No files require special attention.

Reviews (1): Last reviewed commit: "fix: expose WhatsApp Baileys socket timi..." | Re-trigger Greptile

@velvet-shark velvet-shark force-pushed the codex/whatsapp-baileys-socket-timing branch from 8e6b1e8 to d3e3f42 Compare April 28, 2026 13:44
@velvet-shark velvet-shark force-pushed the codex/whatsapp-baileys-socket-timing branch from d3e3f42 to d347552 Compare April 28, 2026 13:45
@velvet-shark velvet-shark merged commit dd643c8 into main Apr 28, 2026
56 of 58 checks passed
@velvet-shark velvet-shark deleted the codex/whatsapp-baileys-socket-timing branch April 28, 2026 13:46
@velvet-shark
Copy link
Copy Markdown
Member Author

Merged via squash.

Thanks @velvet-shark!

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

Labels

channel: whatsapp-web Channel integration: whatsapp-web docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WhatsApp bridge: makeWASocket config passthrough — expose Baileys socket timing and proxy options

1 participant