Stop dropping Tiny lookups during webhook bursts
All checks were successful
Build and Deploy / build-and-push (push) Successful in 49s

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 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-08 14:57:53 -03:00
parent 39f0de34f2
commit 54ffbe1b04
2 changed files with 5 additions and 2 deletions

View File

@@ -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

View File

@@ -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<void> = Promise.resolve();
let liveTinyNextRequestAt = 0;
let liveTinyPendingRequests = 0;