Skip to content

Commit 31ec996

Browse files
authored
Disable remote bindings with the --local flag (#10657)
* Disable remote bindings with the --local flag * Disable remote bindings with --local flag This change disables remote bindings when using the --local flag.
1 parent 60631d5 commit 31ec996

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

.changeset/swift-buses-design.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Disable remote bindings with the `--local` flag

packages/wrangler/e2e/remote-binding/wrangler-remote-resources.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,57 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
558558
}
559559
);
560560

561+
test.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
562+
"`wrangler dev --local` disables remote bindings",
563+
async () => {
564+
const helper = new WranglerE2ETestHelper();
565+
await helper.seed(path.resolve(__dirname, "./workers"));
566+
567+
const kvId = await helper.kv(false);
568+
await helper.run(
569+
`wrangler kv key put --remote --namespace-id=${kvId} test-key remote-value`
570+
);
571+
await helper.run(
572+
`wrangler kv key put --namespace-id=${kvId} test-key local-value`
573+
);
574+
575+
await helper.seed({
576+
"wrangler.json": JSON.stringify(
577+
{
578+
name: "mixed-remote-bindings-test",
579+
main: "mixed-kvs.js",
580+
compatibility_date: "2025-01-01",
581+
kv_namespaces: [
582+
{
583+
binding: "KV_LOCAL_BINDING",
584+
id: kvId,
585+
},
586+
{
587+
binding: "KV_REMOTE_BINDING",
588+
id: kvId,
589+
remote: true,
590+
},
591+
],
592+
},
593+
null,
594+
2
595+
),
596+
});
597+
598+
const worker = helper.runLongLived("wrangler dev --local");
599+
600+
const { url } = await worker.waitForReady();
601+
602+
const response = await fetchText(url);
603+
604+
// We expect both "local" and "remote" KVs to return the local value, since remote bindings are disabled
605+
expect(response).toMatchInlineSnapshot(`
606+
"The kv local value is: local-value
607+
The kv remote value is local-value"
608+
`);
609+
}
610+
);
611+
561612
describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
562613
"Wrangler dev uses a provided account_id from the wrangler config file",
563614
() => {

packages/wrangler/src/dev.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ export const dev = createCommand({
5757
overrideExperimentalFlags: (args) => ({
5858
MULTIWORKER: Array.isArray(args.config),
5959
RESOURCES_PROVISION: args.experimentalProvision ?? false,
60-
REMOTE_BINDINGS: args.experimentalRemoteBindings ?? true,
60+
REMOTE_BINDINGS: args.local
61+
? false
62+
: args.experimentalRemoteBindings ?? true,
6163
DEPLOY_REMOTE_DIFF_CHECK: false,
6264
}),
6365
},

0 commit comments

Comments
 (0)