diff --git a/apps/webhook-service/src/config.ts b/apps/webhook-service/src/config.ts index b436e67..0806333 100644 --- a/apps/webhook-service/src/config.ts +++ b/apps/webhook-service/src/config.ts @@ -206,7 +206,7 @@ export function parseConfig(env: Environment = process.env): WebhookServiceConfi webhookCacheMax: integer('WEBHOOK_CACHE_MAX', env.WEBHOOK_CACHE_MAX, 1_000, 1, 10_000), webhookCacheTtlMs: integer('WEBHOOK_CACHE_TTL_MS', env.WEBHOOK_CACHE_TTL_MS, 60_000, 1_000, 3_600_000), intakeQueueMax: integer('WEBHOOK_INTAKE_QUEUE_MAX', env.WEBHOOK_INTAKE_QUEUE_MAX, 512, 1, 10_000), - intakeBatchMax: integer('WEBHOOK_INTAKE_BATCH_MAX', env.WEBHOOK_INTAKE_BATCH_MAX, 128, 1, 1_000), + intakeBatchMax: integer('WEBHOOK_INTAKE_BATCH_MAX', env.WEBHOOK_INTAKE_BATCH_MAX, 512, 1, 10_000), intakeEventMaxBytes: integer( 'WEBHOOK_INTAKE_EVENT_MAX_BYTES', env.WEBHOOK_INTAKE_EVENT_MAX_BYTES, diff --git a/apps/webhook-service/src/lib/jetstream.ts b/apps/webhook-service/src/lib/jetstream.ts index ce1a67f..db1eb3e 100644 --- a/apps/webhook-service/src/lib/jetstream.ts +++ b/apps/webhook-service/src/lib/jetstream.ts @@ -245,7 +245,8 @@ export class JetstreamClient { } this.lastAckedCursor = opts.cursor this.maxQueue = opts.maxQueue ?? config.intakeQueueMax - this.batchMax = opts.batchMax ?? config.intakeBatchMax + // A batch is drawn from the queue, so it can never usefully exceed it. + this.batchMax = Math.min(opts.batchMax ?? config.intakeBatchMax, this.maxQueue) this.maxEventBytes = opts.maxEventBytes ?? config.intakeEventMaxBytes this.reconnectMinMs = opts.reconnectMinMs ?? config.jetstreamReconnectMinMs this.reconnectMaxMs = opts.reconnectMaxMs ?? config.jetstreamReconnectMaxMs