From 54ffbe1b042bcbb189ba2349ac05eb14c718bc60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Thu, 8 Oct 2026 14:57:53 -0300 Subject: [PATCH] Stop dropping Tiny lookups during webhook bursts When more than ~5 webhooks arrived together, the 6s-spaced live Tiny queue exceeded the 30s max wait and forwarded the order without Tiny data: empty fone and forma_envio, so n8n silently sent no WhatsApp message (19 such drops on 2026-10-08 alone). Tiny is acked before the lookup, so waiting only adds latency. Raise the default max queue wait to 15 minutes so it stays a last-resort valve instead of something an ordinary burst can hit. Co-Authored-By: Claude Opus 5.5 --- docker-compose.yml | 2 +- src/controllers/webhook.controller.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 605dcf1..c6bd799 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -42,7 +42,7 @@ services: - TINY_FETCH_SELLER_DETAILS=${TINY_FETCH_SELLER_DETAILS:-false} - TINY_ORDER_DETAILS_CACHE_TTL_MS=${TINY_ORDER_DETAILS_CACHE_TTL_MS:-120000} - TINY_LIVE_REQUEST_DELAY_MS=${TINY_LIVE_REQUEST_DELAY_MS:-6000} - - TINY_LIVE_MAX_QUEUE_WAIT_MS=${TINY_LIVE_MAX_QUEUE_WAIT_MS:-30000} + - TINY_LIVE_MAX_QUEUE_WAIT_MS=${TINY_LIVE_MAX_QUEUE_WAIT_MS:-900000} # Optional: If you use a shared Docker network for Nginx Proxy Manager, you can attach it here: # networks: # - nginx-proxy-manager-network diff --git a/src/controllers/webhook.controller.ts b/src/controllers/webhook.controller.ts index 86cb999..287a8fd 100644 --- a/src/controllers/webhook.controller.ts +++ b/src/controllers/webhook.controller.ts @@ -26,7 +26,10 @@ const numberEnv = (name: string, fallback: number) => { return Number.isFinite(value) && value >= 0 ? value : fallback; }; const LIVE_TINY_REQUEST_DELAY_MS = numberEnv('TINY_LIVE_REQUEST_DELAY_MS', 6000); -const LIVE_TINY_MAX_QUEUE_WAIT_MS = numberEnv('TINY_LIVE_MAX_QUEUE_WAIT_MS', 30000); +// Tiny is acked before the lookup, so queueing costs only latency. Skipping the lookup +// forwards an order with no phone or forma_envio, which n8n can't notify. Keep this a +// last-resort valve (~150 queued webhooks at 6s), not something a burst can hit. +const LIVE_TINY_MAX_QUEUE_WAIT_MS = numberEnv('TINY_LIVE_MAX_QUEUE_WAIT_MS', 900000); let liveTinyQueueTail: Promise = Promise.resolve(); let liveTinyNextRequestAt = 0; let liveTinyPendingRequests = 0;