Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/swift-buses-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Disable remote bindings with the `--local` flag
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,57 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
}
);

test.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
"`wrangler dev --local` disables remote bindings",
async () => {
const helper = new WranglerE2ETestHelper();
await helper.seed(path.resolve(__dirname, "./workers"));

const kvId = await helper.kv(false);
await helper.run(
`wrangler kv key put --remote --namespace-id=${kvId} test-key remote-value`
);
await helper.run(
`wrangler kv key put --namespace-id=${kvId} test-key local-value`
);

await helper.seed({
"wrangler.json": JSON.stringify(
{
name: "mixed-remote-bindings-test",
main: "mixed-kvs.js",
compatibility_date: "2025-01-01",
kv_namespaces: [
{
binding: "KV_LOCAL_BINDING",
id: kvId,
},
{
binding: "KV_REMOTE_BINDING",
id: kvId,
remote: true,
},
],
},
null,
2
),
});

const worker = helper.runLongLived("wrangler dev --local");

const { url } = await worker.waitForReady();

const response = await fetchText(url);

// We expect both "local" and "remote" KVs to return the local value, since remote bindings are disabled
expect(response).toMatchInlineSnapshot(`
"The kv local value is: local-value
The kv remote value is local-value"
`);
}
);

describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)(
"Wrangler dev uses a provided account_id from the wrangler config file",
() => {
Expand Down
4 changes: 3 additions & 1 deletion packages/wrangler/src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export const dev = createCommand({
overrideExperimentalFlags: (args) => ({
MULTIWORKER: Array.isArray(args.config),
RESOURCES_PROVISION: args.experimentalProvision ?? false,
REMOTE_BINDINGS: args.experimentalRemoteBindings ?? true,
REMOTE_BINDINGS: args.local
? false
: args.experimentalRemoteBindings ?? true,
DEPLOY_REMOTE_DIFF_CHECK: false,
}),
},
Expand Down
Loading