Skip to content

Commit

Permalink
fix: update queues max_batch_timeout in miniflare (#7399)
Browse files Browse the repository at this point in the history
* update timeout limit

* changeset

* test

* remove only

Co-authored-by: Carmen Popoviciu <[email protected]>

---------

Co-authored-by: Carmen Popoviciu <[email protected]>
  • Loading branch information
emily-shen and CarmenPopoviciu authored Dec 2, 2024
1 parent 5739015 commit b3d2e7d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sour-pugs-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"miniflare": patch
---

fix: update queues max_batch_timeout limit from 30s to 60s
2 changes: 1 addition & 1 deletion packages/miniflare/src/workers/queues/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
29 changes: 29 additions & 0 deletions packages/miniflare/test/plugins/queues/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
DeferredPromise,
LogLevel,
Miniflare,
MiniflareCoreError,
QUEUES_PLUGIN_NAME,
QueuesError,
Response,
Expand Down Expand Up @@ -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[][] = [];

Expand Down

0 comments on commit b3d2e7d

Please sign in to comment.