Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
Merge pull request #1234 from rmyndharis/fix/auto-start-does-not-block-the-listener
Yudhi Armyndharisb0d1df8ed872
diff --cc CHANGELOG.mdindex 76e719f33,51eaacc6a..ac5e0f690--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -44,12 -44,9 +44,14 @@@ 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.++- A plugin loaded from the legacy plugins directory can be enabled, uninstalled and updated like any other. The loader scans that directory in addition to the configured one, but recorded nothing about where each package came from, so every later operation built its path as `<plugins.dir>/<id>`: enabling failed with a missing entry file and left the plugin in `ERROR`, uninstalling deleted the storage directory and reported success while the code stayed on disk and reloaded on the next boot, updating renamed a directory that was not there, and the config UI answered `404`. Each plugin now carries the directory it was loaded from, and installing still writes to the configured one.+ - Auto-starting previously authenticated sessions no longer delays the HTTP listener. NestJS binds the port only after every bootstrap hook has finished, and the auto-start loop launches one engine at a time with a 2s throttle, each bounded only by the engine-init timeout of at least 60 seconds — so a host with several sessions kept the port closed, not merely unhealthy, for minutes. The Helm chart's liveness budget is roughly 50 seconds and the Docker `HEALTHCHECK` encodes the same expectation, so a restart could be killed before it ever answered, and no probe budget can cover a bound that grows with the session count. The launches now run after the port is open; a shutdown that lands mid-run stops the remaining launches and waits for the one in flight. A failure of the session scan itself is now logged instead of aborting startup.+### 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.