Skip to content
Open
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
7 changes: 7 additions & 0 deletions .changeset/silent-queues-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

Allow `wrangler dev --remote` to start when queue producer bindings are configured

Queue bindings are still unsupported in legacy remote dev mode, but Wrangler now omits them from remote preview uploads after warning. This lets unrelated routes keep working instead of returning 500 errors for the whole dev session.
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,44 @@ describe("ConfigController", () => {

expect(warningCount).toBe(1);
});

it("should warn when queues are configured in remote dev mode", async ({
expect,
}) => {
await seed({
"src/index.ts": dedent /* javascript */ `
export default {
fetch() {
return new Response("hello world")
}
}
`,
"wrangler.toml": dedent /* toml */ `
name = "my-worker"
main = "src/index.ts"
compatibility_date = "2024-06-01"

[[queues.producers]]
binding = "QUEUE"
queue = "test-queue"
`,
});

const event = bus.waitFor("configUpdate");
await controller.set({
config: "./wrangler.toml",
dev: {
remote: true,
auth: {
accountId: "some-account-id",
apiToken: { apiToken: "some-api-token" },
},
},
});
await event;

expect(std.warn).toContain(
"Queues are not yet supported in wrangler dev remote mode."
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,42 @@ describe("RemoteRuntimeController", () => {
vi.mocked(getAccessHeaders).mockResolvedValue({});
});

describe("unsupported queue bindings", () => {
it("should omit queue producer bindings from remote preview uploads", async ({
expect,
}) => {
const { controller, bus } = setup();
const config = makeConfig({
bindings: {
QUEUE: {
type: "queue",
queue_name: "test-queue",
},
KV: {
type: "kv_namespace",
id: "test-kv-namespace",
},
},
});
const bundle = makeBundle();

controller.onBundleStart({ type: "bundleStart", config });
controller.onBundleComplete({ type: "bundleComplete", config, bundle });
await bus.waitFor("reloadComplete");

expect(createRemoteWorkerInit).toHaveBeenCalledWith(
expect.objectContaining({
bindings: {
KV: {
type: "kv_namespace",
id: "test-kv-namespace",
},
},
})
);
});
});

describe("stale bundle bail-out", () => {
it("should skip stale bundles and only reload once for rapid updates", async ({
expect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ import type {
ReloadCompleteEvent,
ReloadStartEvent,
} from "./events";
import type { Bundle, StartDevWorkerOptions, Trigger } from "./types";
import type { Binding, Bundle, StartDevWorkerOptions, Trigger } from "./types";
import type { Route } from "@cloudflare/workers-utils";

type CreateRemoteWorkerInitProps = Parameters<typeof createRemoteWorkerInit>[0];

function getRemotePreviewBindings(
bindings: StartDevWorkerOptions["bindings"]
): Record<string, Binding> {
return Object.fromEntries(
Object.entries(bindings ?? {}).filter(
([, binding]) => binding.type !== "queue"
)
);
}
Comment thread
akim136 marked this conversation as resolved.

export class RemoteRuntimeController extends RuntimeController {
#abortController = new AbortController();

Expand Down Expand Up @@ -154,7 +164,7 @@ export class RemoteRuntimeController extends RuntimeController {
assets: props.assets,
legacyAssetPaths: props.legacyAssetPaths,
format: props.format,
bindings: props.bindings,
bindings: getRemotePreviewBindings(props.bindings),
compatibilityDate: props.compatibilityDate,
compatibilityFlags: props.compatibilityFlags,
});
Expand Down