Skip to content

Commit 443b6cb

Browse files
make sure startWorker doesn't connect to remote bindings when localBindingsOnly is set
1 parent 4ebead9 commit 443b6cb

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

packages/wrangler/e2e/remote-binding/start-worker-remote-bindings.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,38 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)("startWorker - remote bindings", () => {
124124
await worker.dispose();
125125
});
126126
});
127+
128+
it("doesn't connect to remote bindings when `localBindingsOnly` is set", async () => {
129+
const helper = new WranglerE2ETestHelper();
130+
await helper.seed(resolve(__dirname, "./workers"));
131+
await helper.seed({
132+
"wrangler.json": JSON.stringify({
133+
name: "remote-bindings-test",
134+
main: "ai.js",
135+
compatibility_date: "2025-05-07",
136+
ai: {
137+
binding: "AI",
138+
remote: true,
139+
},
140+
}),
141+
});
142+
143+
await expect(
144+
(async () => {
145+
const worker = await startWorker({
146+
config: `${helper.tmpPath}/wrangler.json`,
147+
dev: {
148+
inspector: false,
149+
server: { port: 0 },
150+
localBindingsOnly: true,
151+
},
152+
});
153+
154+
await worker.ready;
155+
156+
await worker.fetch("http://example.com");
157+
})()
158+
).rejects.toThrowErrorMatchingInlineSnapshot(
159+
`[Error: Binding AI needs to be run remotely]`
160+
);
161+
});

packages/wrangler/src/api/startDevWorker/ConfigController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ async function resolveDevConfig(
126126
return {
127127
auth,
128128
remote: input.dev?.remote,
129+
localBindingsOnly: input.dev?.localBindingsOnly,
129130
server: {
130131
hostname: input.dev?.server?.hostname || config.dev.ip,
131132
port:

0 commit comments

Comments
 (0)