Skip to content

Commit

Permalink
fix(miniflare): Fix regression introduced in #5570
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmenPopoviciu committed Aug 16, 2024
1 parent a9b4f25 commit e7f1755
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions packages/miniflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,20 @@ function getQueueProducers(
);
}

for (const [bindingName, opts] of Object.entries(workerProducers)) {
queueProducers.set(bindingName, { workerName, ...opts });
type Entries<T> = { [K in keyof T]: [K, T[K]] }[keyof T][];
type ProducersIterable = Entries<typeof workerProducers>;
const producersIterable = Object.entries(workerProducers) as ProducersIterable;

for (const [bindingName, opts] of producersIterable) {
if(typeof opts === "string") {
// queueProducers: { "MY_QUEUE": "my-queue" }
queueProducers.set(bindingName, { workerName, queueName: opts });
} else {
opts
// queueProducers: ["MY_QUEUE"] or
// queueProducers: { QUEUE: { queueName: "QUEUE", ... } }
queueProducers.set(bindingName, { workerName, ...opts });
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/miniflare/test/plugins/queues/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ test("supports message contentTypes", async (t) => {
test("validates message size", async (t) => {
const mf = new Miniflare({
verbose: true,
queueProducers: ["QUEUE"],
queueProducers: {"QUEUE": "my-queue"},
modules: true,
script: `export default {
async fetch(request, env, ctx) {
Expand Down

0 comments on commit e7f1755

Please sign in to comment.