Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(config): refuse a negative reaper or reconciler interval at boot
Yudhi Armyndharis63fb68def5da
diff --git a/src/config/env.validation.spec.ts b/src/config/env.validation.spec.tsindex 5458ecba1..a1720e9a9 100644--- a/src/config/env.validation.spec.ts+++ b/src/config/env.validation.spec.ts@@ -697,6 +697,15 @@ describe('validateEnv', () => {expect(() => validateEnv({ [key]: '2147483647' })).not.toThrow();});+ // 0 disables each sweep; a negative value used to boot clean and keep the sweep running.+ it.each(['MESSAGE_REAPER_INTERVAL_MS', 'WEBHOOK_RECONCILE_INTERVAL_MS', 'INGRESS_RECONCILE_INTERVAL_MS'])(+ 'rejects a negative %s and keeps 0 as the off switch',+ key => {+ expect(() => validateEnv({ [key]: '-1' })).toThrow(new RegExp(`${key} must be a non-negative integer`));+ expect(() => validateEnv({ [key]: '0' })).not.toThrow();+ },+ );+it('rejects a SESSION_LEASE_HEARTBEAT_MS above the Node timer ceiling even inside a longer lease', () => {const lease = { SESSION_LEASE_TTL_MS: '5000000000' };expect(() => validateEnv({ ...lease, SESSION_LEASE_HEARTBEAT_MS: '2147483648' })).toThrow(diff --git a/src/config/env.validation.ts b/src/config/env.validation.tsindex c026fd69a..6fbe0a174 100644--- a/src/config/env.validation.ts+++ b/src/config/env.validation.ts@@ -232,6 +232,10 @@ export function validateEnv(config: EnvConfig): EnvConfig {'REDIS_CACHE_DB','INBOUND_MEDIA_GLOBAL_CONCURRENCY', // 0 = no process-wide ceiling, only the per-session one'SHUTDOWN_DELAY_MS', // 0 = no drain; parseInt read `3s` as a 3 ms drain+ // 0 = disabled. A negative value failed the digits-only read and silently kept the default sweep.+ 'MESSAGE_REAPER_INTERVAL_MS',+ 'WEBHOOK_RECONCILE_INTERVAL_MS',+ 'INGRESS_RECONCILE_INTERVAL_MS',]) {checkNonNegativeInt(key);}