Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(docker): forward AUTO_START_SESSIONS to the container (#985)
Yudhi Armyndharisa67902a8cc97
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 81384f897..923563cf5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0npm registry tarball (published from the same commit previously fetched over Git SSH), avoidingnpm 12's `EALLOWGIT` default without weakening its project security policy.+- **`AUTO_START_SESSIONS` set in `.env` now reaches the container under the bundled production+ compose.** `docker-compose.yml` never forwarded the variable — not in any revision of the file — so+ on a stock Docker Compose deployment the flag was inert: previously authenticated sessions were+ reset to `disconnected` at boot and left there, and the operator got no error to work from, because+ nothing was misconfigured from the application's point of view. `.env.example` documents the+ setting, and `docker-compose.dev.yml` did forward it, which made the omission read as a working+ feature everywhere except where most deployments run. The forward is blank-defaulted like the+ neighbouring engine options, so an unset value still resolves to the documented opt-out default and+ only an explicit `true` starts sessions at boot.+- **A whatsapp-web.js session no longer publishes a QR belonging to the browser it is about toreplace** (#982). On `LOGOUT`, whatsapp-web.js deletes the auth profile and re-runs its injectionagainst the same browser, so the old client keeps serving QR codes while the session lifecycle waitsdiff --git a/docker-compose.yml b/docker-compose.ymlindex e906f8a3f..323e83044 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -151,6 +151,10 @@ services:# low-resource hosts where the QR can time out before WA Web loads. Empty = default; see# docs/12-troubleshooting-faq.md. (Without this line the var in .env never reaches the container.)- WWEBJS_AUTH_TIMEOUT_MS=${WWEBJS_AUTH_TIMEOUT_MS:-}+ # Re-start previously authenticated sessions at boot. Opt-in: the app reads the exact string+ # "true", so a blank forward (nothing set) keeps the default off. Without this line the value in+ # .env never reaches the container and the flag silently does nothing.+ - AUTO_START_SESSIONS=${AUTO_START_SESSIONS:-}# Storage. Blank-forwarded (see Database note) so a dashboard local↔S3 switch applies; a real# host value pins. Credentials use the canonical S3_ACCESS_KEY_ID / S3_SECRET_ACCESS_KEY names the# app and dashboard write; the legacy S3_ACCESS_KEY / S3_SECRET_KEY are ALSO forwarded (and readdiff --git a/src/config/feature-flags.spec.ts b/src/config/feature-flags.spec.tsindex d5519716b..925384483 100644--- a/src/config/feature-flags.spec.ts+++ b/src/config/feature-flags.spec.ts@@ -1,3 +1,5 @@+import * as fs from 'fs';+import * as path from 'path';import { computeFeatureFlags, resolveFeatureFlags, FeatureFlags } from './feature-flags';describe('feature-flags', () => {@@ -70,4 +72,14 @@ describe('feature-flags', () => {expect(resolveFeatureFlags(configService).autoStartSessions).toBe(true);});});++ // A flag the app reads is useless if the bundled compose never hands it to the container: the+ // operator sets it in .env, nothing happens, and there is no error to go on. That was the state of+ // AUTO_START_SESSIONS until this guard landed, so assert the forward exists rather than trusting it.+ describe('bundled production compose', () => {+ it('forwards AUTO_START_SESSIONS to the container', () => {+ const compose = fs.readFileSync(path.join(__dirname, '../../docker-compose.yml'), 'utf8');+ expect(compose).toMatch(/^\s*- AUTO_START_SESSIONS=\$\{AUTO_START_SESSIONS:-\}$/m);+ });+ });});