To prevent memory exhaustion from unbounded waiter accumulation, we have introduced a Hard Queue Cap.
- Policy: When
queue.length >= maxQueueDepth, the system rejects withRateLimitQueueFullError. - Error type:
RateLimitQueueFullError(code: 'RATE_LIMIT_QUEUE_FULL') — anErrorsubclass carrying theproviderIdand the cap value. Callers should catch this error to route the request to the Dead Letter Queue (DLQ). - Config: Set via
WEBHOOK_MAX_QUEUE_DEPTHenv var (default:1000), validated alongsideWEBHOOK_BUCKET_CAPACITYandWEBHOOK_REFILL_RATE_PER_SECinloadWebhookTokenBucketConfig. Must be a finite positive integer. - Monitoring: Rejections are recorded via
recordQueueOverflow()inwebhookMetrics.ts(zero-label counter — no cardinality risk) to trigger alerts before service degradation occurs. - FIFO ordering: Waiters already in the queue below the cap continue to drain in FIFO order. New acquisitions are accepted again once the queue drops below the cap.