Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update queues max_batch_timeout in miniflare #7399

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading