Skip to content

Commit c3ed531

Browse files
Various fixes/improvements around remote bindings being used as local (#11162)
* Fix the fact that some remote bindings, such as AI still work as remote under `wrangler dev --local` * Fix bindings with `remote: true` being logged as `remote` when run via `wrangler dev --local` * remote outdated tsdoc param * Update the description of the `--local` flag for the `wrangler dev` command to clarify that it disables remote bindings, also un-deprecate and un-hide it * make sure that `getPlatformProxy` and the vite plugin have a `remoteBindings` option that can be used to disable remote bindings --------- Co-authored-by: Somhairle MacLeòid <[email protected]>
1 parent 05440a1 commit c3ed531

File tree

24 files changed

+295
-59
lines changed

24 files changed

+295
-59
lines changed

.changeset/cyan-pets-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/vite-plugin": minor
3+
---
4+
5+
add a `remoteBindings` option to allow the disabling of remote bindings

.changeset/modern-foxes-dream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
add a `remoteBindings` option to `getPlatformProxy` to allow the disabling of remote bindings

.changeset/shy-teams-appear.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+
Update the description of the `--local` flag for the `wrangler dev` command to clarify that it disables remote bindings, also un-deprecate and un-hide it

.changeset/thirty-lights-build.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+
Fix bindings with `remote: true` being logged as `remote` when run via `wrangler dev --local`
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { describe, expect, test } from "vitest";
2+
import { getPlatformProxy } from "wrangler";
3+
import type { Ai } from "@cloudflare/workers-types/experimental";
4+
5+
describe("getPlatformProxy - remote bindings with remoteBindings: false", () => {
6+
test("getPlatformProxy works with remote bindings", async () => {
7+
const { env, dispose } = await getPlatformProxy<{
8+
AI: Ai;
9+
}>({
10+
configPath: "./wrangler.remote-bindings-false.jsonc",
11+
remoteBindings: false,
12+
});
13+
14+
await expect(
15+
env.AI.run("@cf/meta/llama-3.1-8b-instruct-fp8", {
16+
messages: [],
17+
})
18+
).rejects.toThrowErrorMatchingInlineSnapshot(
19+
`[Error: Binding AI needs to be run remotely]`
20+
);
21+
22+
await dispose();
23+
});
24+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "get-platform-proxy-remote-bindings-with-local-bindings-only-test",
3+
"compatibility_date": "2025-05-07",
4+
"ai": {
5+
"binding": "AI",
6+
"remote": true,
7+
},
8+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@cloudflare/vite-plugin-e2e-remote-bindings-disabled",
3+
"version": "0.0.0",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"build": "vite build",
8+
"buildAndPreview": "vite build && vite preview",
9+
"dev": "vite",
10+
"lint": "eslint .",
11+
"preview": "vite preview"
12+
},
13+
"devDependencies": {
14+
"@cloudflare/vite-plugin": "*",
15+
"@cloudflare/workers-types": "^4.20250204.0",
16+
"@eslint/js": "^9.19.0",
17+
"eslint": "^9.19.0",
18+
"eslint-plugin-react-hooks": "^5.0.0",
19+
"eslint-plugin-react-refresh": "^0.4.18",
20+
"globals": "^15.14.0",
21+
"typescript": "~5.7.2",
22+
"typescript-eslint": "^8.22.0",
23+
"vite": "^6.1.0"
24+
}
25+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
async fetch(_req, env) {
3+
const content = await env.AI.run("@cf/meta/llama-2-7b-chat-fp16", {
4+
messages: [],
5+
});
6+
7+
return Response.json({
8+
response: content.response,
9+
});
10+
},
11+
} satisfies ExportedHandler<{ AI: Ai }>;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"files": [],
3+
"references": [
4+
{ "path": "./tsconfig.node.json" },
5+
{ "path": "./tsconfig.worker.json" }
6+
]
7+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4+
"target": "ES2022",
5+
"lib": ["ES2023"],
6+
"module": "ESNext",
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
10+
"moduleResolution": "bundler",
11+
"allowImportingTsExtensions": true,
12+
"isolatedModules": true,
13+
"moduleDetection": "force",
14+
"noEmit": true,
15+
16+
/* Linting */
17+
"strict": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedSideEffectImports": true
22+
},
23+
"include": ["vite.config.ts"]
24+
}

0 commit comments

Comments
 (0)