Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68fac8a

Browse files
fix(wrangler) remove putQueue call when deploying a worker with queue producer binding (#10288)
* MQ-861: Remove putQueue call when setting queue producer binding * remove calls to mockPutQueueById in tests * Update .changeset/chatty-pens-sniff.md Co-authored-by: Pete Bacon Darwin <[email protected]> * try to ensure that the required deploy workers job is not skipped * test: add a waitFor around log check for email bindings --------- Co-authored-by: Pete Bacon Darwin <[email protected]> Co-authored-by: Peter Bacon Darwin <[email protected]>
1 parent 951baa5 commit 68fac8a

File tree

4 files changed

+15
-74
lines changed

4 files changed

+15
-74
lines changed

.changeset/chatty-pens-sniff.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Do not attempt to update queue producer settings when deploying a Worker with a queue binding
6+
7+
Previously, each deployed Worker would update a subset of the queue producer's settings for each queue binding, which could result in broken queue producers or at least conflicts where different Workers tried to set different producer settings on a shared queue.

packages/wrangler/src/__tests__/deploy.test.ts

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ import { writeWranglerConfig } from "./helpers/write-wrangler-config";
5656
import type { AssetManifest } from "../assets";
5757
import type { Config } from "../config";
5858
import type { CustomDomain, CustomDomainChangeset } from "../deploy/deploy";
59-
import type {
60-
PostQueueBody,
61-
PostTypedConsumerBody,
62-
QueueResponse,
63-
} from "../queues/client";
59+
import type { PostTypedConsumerBody, QueueResponse } from "../queues/client";
6460
import type { FormData } from "undici";
6561
import type { Mock } from "vitest";
6662

@@ -11941,10 +11937,6 @@ export default{
1194111937
modified_on: "",
1194211938
};
1194311939
mockGetQueueByName(queueName, existingQueue);
11944-
mockPutQueueById(queueId, {
11945-
queue_name: queueName,
11946-
settings: {},
11947-
});
1194811940

1194911941
await runWrangler("deploy index.js");
1195011942
expect(std.out).toMatchInlineSnapshot(`
@@ -11987,12 +11979,7 @@ export default{
1198711979
modified_on: "",
1198811980
};
1198911981
mockGetQueueByName(queueName, existingQueue);
11990-
mockPutQueueById(queueId, {
11991-
queue_name: queueName,
11992-
settings: {
11993-
delivery_delay: 10,
11994-
},
11995-
});
11982+
1199611983
await runWrangler("deploy index.js");
1199711984
expect(std.out).toMatchInlineSnapshot(`
1199811985
"Total Upload: xx KiB / gzip: xx KiB
@@ -13928,37 +13915,6 @@ function mockPostConsumerById(
1392813915
return requests;
1392913916
}
1393013917

13931-
function mockPutQueueById(
13932-
expectedQueueId: string,
13933-
expectedBody: PostQueueBody
13934-
) {
13935-
const requests = { count: 0 };
13936-
msw.use(
13937-
http.put(
13938-
`*/accounts/:accountId/queues/:queueId`,
13939-
async ({ request, params }) => {
13940-
const body = await request.json();
13941-
expect(params.queueId).toEqual(expectedQueueId);
13942-
expect(params.accountId).toEqual("some-account-id");
13943-
expect(body).toEqual(expectedBody);
13944-
requests.count += 1;
13945-
return HttpResponse.json({
13946-
success: true,
13947-
errors: [],
13948-
messages: [],
13949-
result: {
13950-
queue: expectedBody.queue_name,
13951-
settings: {
13952-
delivery_delay: expectedBody.settings?.delivery_delay,
13953-
},
13954-
},
13955-
});
13956-
}
13957-
)
13958-
);
13959-
return requests;
13960-
}
13961-
1396213918
function mockPostQueueHTTPConsumer(
1396313919
expectedQueueId: string,
1396413920
expectedBody: PostTypedConsumerBody

packages/wrangler/src/deploy/deploy.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import {
3535
postConsumer,
3636
putConsumer,
3737
putConsumerById,
38-
putQueue,
3938
} from "../queues/client";
4039
import { syncLegacyAssets } from "../sites";
4140
import {
@@ -66,7 +65,7 @@ import type {
6665
CfPlacement,
6766
CfWorkerInit,
6867
} from "../deployment-bundle/worker";
69-
import type { PostQueueBody, PostTypedConsumerBody } from "../queues/client";
68+
import type { PostTypedConsumerBody } from "../queues/client";
7069
import type { LegacyAssetPaths } from "../sites";
7170
import type { RetrieveSourceMapFunction } from "../sourcemap";
7271
import type { ApiVersion, Percentage, VersionId } from "../versions/types";
@@ -1182,29 +1181,6 @@ export function isAuthenticationError(e: unknown): e is ParseError {
11821181
return e instanceof ParseError && (e as { code?: number }).code === 10000;
11831182
}
11841183

1185-
export async function updateQueueProducers(
1186-
config: Config
1187-
): Promise<Promise<string[]>[]> {
1188-
const producers = config.queues.producers || [];
1189-
const updateProducers: Promise<string[]>[] = [];
1190-
for (const producer of producers) {
1191-
const body: PostQueueBody = {
1192-
queue_name: producer.queue,
1193-
settings: {
1194-
delivery_delay: producer.delivery_delay,
1195-
},
1196-
};
1197-
1198-
updateProducers.push(
1199-
putQueue(config, producer.queue, body).then(() => [
1200-
`Producer for ${producer.queue}`,
1201-
])
1202-
);
1203-
}
1204-
1205-
return updateProducers;
1206-
}
1207-
12081184
export async function updateQueueConsumers(
12091185
scriptName: string | undefined,
12101186
config: Config

packages/wrangler/src/triggers/deploy.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
publishRoutes,
88
renderRoute,
99
updateQueueConsumers,
10-
updateQueueProducers,
1110
validateRoutes,
1211
} from "../deploy/deploy";
1312
import { UserError } from "../errors";
@@ -274,8 +273,11 @@ export default async function triggersDeploy(
274273
}
275274

276275
if (config.queues.producers && config.queues.producers.length) {
277-
const updateProducers = await updateQueueProducers(config);
278-
deployments.push(...updateProducers);
276+
deployments.push(
277+
...config.queues.producers.map((producer) =>
278+
Promise.resolve([`Producer for ${producer.queue}`])
279+
)
280+
);
279281
}
280282

281283
if (config.queues.consumers && config.queues.consumers.length) {

0 commit comments

Comments
 (0)