Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
Merge pull request #1231 from rmyndharis/fix/session-stop-mark-reclaimed-on-404
Yudhi Armyndharis02f3848c1877
diff --cc CHANGELOG.mdindex 335fc4c88,358dee6fd..015c39e89--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -44,8 -43,9 +44,10 @@@ and this project adheres to [Semantic V- A WhatsApp Web build that cannot be resolved from the wa-version registry is now reported (`web_version_resolve_failed`) with the reason, the registry URL and the remedy. A host that cannot reach the registry — a proxy, a firewalled VPS, regional blocking — silently continued without a pin and let whatsapp-web.js pick the build itself, which is the "authenticates then never reaches ready" class the pin exists to prevent; nothing was logged, so there was nothing to grep for. The existing one-minute backoff already bounds how often the warning can repeat.- `POST /sessions/:id/pairing-code` answers `409` while a whatsapp-web.js session is still starting up, instead of a `500` carrying a raw `TypeError`. The engine stored its client before launching Chromium, so for the whole launch — seconds on a modest host — the route passed its only guard and reached into a browser page that did not exist yet. Requesting a code straight after `POST /start`, which is what the dashboard's linking modal invites, landed in exactly that window. The request is now accepted only once the session reaches `qr_ready`, the state the pairing flow needs anyway.- A burst of inbound media messages no longer loses the media of everything past the eighth. The Baileys adapter capped the download queue at its active slots, and an upsert is submitted in one synchronous pass, so admission was a constant 8 whatever the batch size — a 40-message upsert arrived with 32 of its files replaced by an omitted-media marker. The queue is now unbounded and a burst parks instead of shedding; the concurrent-download bound is unchanged.+- The JavaScript SDK reports why a production gateway rejected a request instead of ending the error message in `[object Object]`. NestJS omits `error` from the envelope whenever the exception carried no explicit message, which is what the global ValidationPipe does under `disableErrorMessages` — the default whenever `NODE_ENV=production` and `VALIDATION_ERROR_DETAIL` is unset — so every rejected request in a stock production deployment answers `{ statusCode, message }`. The SDK required all three keys to recognise the envelope; the PHP, Python and Go clients already treated `error` as optional.+ - Stopping or deleting a session id that does not exist no longer leaves an entry behind in the teardown-mark set. The mark is set synchronously at entry, before the existence check, so a `404` set one too — and nothing could remove it, because the two paths that clear a mark both run after their own lookup and a session id is never re-supplied. The set grew by one for every such request until the process restarted. A refusal against a session that does exist still keeps its mark, which is what the mark is for.+### Security- An advisory usage-statistics write no longer persists the whole API-key row. A key deleted while a request that had already loaded it was in flight was re-inserted with its original hash and authenticated again; a revocation or a narrowing of role, allowlist, IP allowlist or expiry was likewise reverted to the values that request loaded. The write is now scoped to the two usage columns and affects nothing if the row is gone.