diff --git a/.changeset/sour-pugs-agree.md b/.changeset/sour-pugs-agree.md new file mode 100644 index 000000000000..1ab79786e5e0 --- /dev/null +++ b/.changeset/sour-pugs-agree.md @@ -0,0 +1,5 @@ +--- +"miniflare": patch +--- + +fix: update queues max_batch_timeout limit from 30s to 60s diff --git a/packages/miniflare/src/workers/queues/schemas.ts b/packages/miniflare/src/workers/queues/schemas.ts index 0b90bd2c3917..0a3ead4e4135 100644 --- a/packages/miniflare/src/workers/queues/schemas.ts +++ b/packages/miniflare/src/workers/queues/schemas.ts @@ -26,7 +26,7 @@ export const QueueConsumerOptionsSchema = /* @__PURE__ */ z // 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 + maxBatchTimeout: z.number().min(0).max(60).optional(), // seconds maxRetires: z.number().min(0).max(100).optional(), // deprecated maxRetries: z.number().min(0).max(100).optional(), deadLetterQueue: z.ostring(), diff --git a/packages/miniflare/test/plugins/queues/index.spec.ts b/packages/miniflare/test/plugins/queues/index.spec.ts index caa4224bda1b..e80f8b7358f6 100644 --- a/packages/miniflare/test/plugins/queues/index.spec.ts +++ b/packages/miniflare/test/plugins/queues/index.spec.ts @@ -3,6 +3,7 @@ import { DeferredPromise, LogLevel, Miniflare, + MiniflareCoreError, QUEUES_PLUGIN_NAME, QueuesError, Response, @@ -40,6 +41,34 @@ async function getControlStub( return stub; } +test("maxBatchTimeout validation", async (t) => { + const mf = new Miniflare({ + verbose: true, + queueConsumers: { + QUEUE: { maxBatchTimeout: 60 }, + }, + modules: true, + script: "", + }); + t.throws( + () => + new Miniflare({ + verbose: true, + queueConsumers: { + QUEUE: { maxBatchTimeout: 61 }, + }, + modules: true, + script: "", + }), + { + instanceOf: MiniflareCoreError, + code: "ERR_VALIDATION", + message: /Number must be less than or equal to 60/, + } + ); + t.teardown(() => mf.dispose()); +}); + test("flushes partial and full batches", async (t) => { let batches: string[][] = [];