From 3c03c921a2cdfd11ba4d17599258ac3f706323c8 Mon Sep 17 00:00:00 2001 From: Siddhant Date: Mon, 30 Sep 2024 14:48:02 -0500 Subject: [PATCH] chore: fix typo for `maxRetries` in queues configuration --- .../src/workers/queues/broker.worker.ts | 2 +- .../miniflare/src/workers/queues/schemas.ts | 27 ++++++++++++------- .../test/plugins/queues/index.spec.ts | 8 +++--- packages/wrangler/src/dev/miniflare.ts | 2 +- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/packages/miniflare/src/workers/queues/broker.worker.ts b/packages/miniflare/src/workers/queues/broker.worker.ts index f5d8368379ee..ec02d1cdb276 100644 --- a/packages/miniflare/src/workers/queues/broker.worker.ts +++ b/packages/miniflare/src/workers/queues/broker.worker.ts @@ -245,7 +245,7 @@ export class QueueBrokerObject extends MiniflareDurableObject; export const QueueProducersSchema = /* @__PURE__ */ z.record(QueueProducerSchema); -export const QueueConsumerOptionsSchema = /* @__PURE__ */ z.object({ - // https://developers.cloudflare.com/queues/platform/configuration/#consumer - // https://developers.cloudflare.com/queues/platform/limits/ - maxBatchSize: z.number().min(0).max(100).optional(), - maxBatchTimeout: z.number().min(0).max(30).optional(), // seconds - maxRetires: z.number().min(0).max(100).optional(), - deadLetterQueue: z.ostring(), - retryDelay: QueueMessageDelaySchema, -}); +export const QueueConsumerOptionsSchema = /* @__PURE__ */ z + .object({ + // https://developers.cloudflare.com/queues/platform/configuration/#consumer + // https://developers.cloudflare.com/queues/platform/limits/ + maxBatchSize: z.number().min(0).max(100).optional(), + maxBatchTimeout: z.number().min(0).max(30).optional(), // seconds + maxRetires: z.number().min(0).max(100).optional(), // deprecated + maxRetries: z.number().min(0).max(100).optional(), + deadLetterQueue: z.ostring(), + retryDelay: QueueMessageDelaySchema, + }) + .transform((queue) => { + if (queue.maxRetires !== undefined) { + queue.maxRetries = queue.maxRetires; + } + + return queue as Omit; + }); export const QueueConsumerSchema = /* @__PURE__ */ z.intersection( QueueConsumerOptionsSchema, z.object({ workerName: z.string() }) diff --git a/packages/miniflare/test/plugins/queues/index.spec.ts b/packages/miniflare/test/plugins/queues/index.spec.ts index 0fbb3471a66f..caa4224bda1b 100644 --- a/packages/miniflare/test/plugins/queues/index.spec.ts +++ b/packages/miniflare/test/plugins/queues/index.spec.ts @@ -306,7 +306,7 @@ test("sends all structured cloneable types", async (t) => { queueProducers: ["QUEUE"], queueConsumers: { - QUEUE: { maxBatchSize: 100, maxBatchTimeout: 0, maxRetires: 0 }, + QUEUE: { maxBatchSize: 100, maxBatchTimeout: 0, maxRetries: 0 }, }, serviceBindings: { async REPORTER(request) { @@ -433,7 +433,7 @@ test("retries messages", async (t) => { log, queueProducers: { QUEUE: { queueName: "queue" } }, queueConsumers: { - queue: { maxBatchSize: 5, maxBatchTimeout: 1, maxRetires: 2 }, + queue: { maxBatchSize: 5, maxBatchTimeout: 1, maxRetries: 2 }, }, serviceBindings: { async RETRY_FILTER(request) { @@ -685,13 +685,13 @@ test("moves to dead letter queue", async (t) => { bad: { maxBatchSize: 5, maxBatchTimeout: 1, - maxRetires: 0, + maxRetries: 0, deadLetterQueue: "dlq", }, dlq: { maxBatchSize: 5, maxBatchTimeout: 1, - maxRetires: 0, + maxRetries: 0, deadLetterQueue: "bad", // (cyclic) }, }, diff --git a/packages/wrangler/src/dev/miniflare.ts b/packages/wrangler/src/dev/miniflare.ts index 87b8c8ee54a0..85dc71821658 100644 --- a/packages/wrangler/src/dev/miniflare.ts +++ b/packages/wrangler/src/dev/miniflare.ts @@ -345,7 +345,7 @@ function queueConsumerEntry(consumer: QueueConsumer) { const options = { maxBatchSize: consumer.max_batch_size, maxBatchTimeout: consumer.max_batch_timeout, - maxRetires: consumer.max_retries, + maxRetries: consumer.max_retries, deadLetterQueue: consumer.dead_letter_queue, retryDelay: consumer.retry_delay, };