diff --git a/.changeset/lemon-colts-melt copy 2.md b/.changeset/lemon-colts-melt copy 2.md new file mode 100644 index 000000000000..3b9071e31a32 --- /dev/null +++ b/.changeset/lemon-colts-melt copy 2.md @@ -0,0 +1,5 @@ +--- +"wrangler": minor +--- + +Enable Remote Bindings without the need for the `--x-remote-bindings` flag diff --git a/.changeset/lemon-colts-melt copy.md b/.changeset/lemon-colts-melt copy.md new file mode 100644 index 000000000000..0eb065615227 --- /dev/null +++ b/.changeset/lemon-colts-melt copy.md @@ -0,0 +1,5 @@ +--- +"@cloudflare/vitest-pool-workers": minor +--- + +Enable Remote Bindings without the need for the `remoteBindings: true` property diff --git a/.changeset/lemon-colts-melt.md b/.changeset/lemon-colts-melt.md new file mode 100644 index 000000000000..5c1e883fc526 --- /dev/null +++ b/.changeset/lemon-colts-melt.md @@ -0,0 +1,5 @@ +--- +"@cloudflare/vite-plugin": minor +--- + +Enable Remote Bindings without the need for the `experimental: { remoteBindings: true }` property diff --git a/fixtures/ai-app/.gitignore b/fixtures/ai-app/.gitignore deleted file mode 100644 index 1521c8b7652b..000000000000 --- a/fixtures/ai-app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/fixtures/ai-app/package.json b/fixtures/ai-app/package.json deleted file mode 100644 index 68b365db6450..000000000000 --- a/fixtures/ai-app/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "@fixture/worker-ai", - "private": true, - "description": "", - "license": "ISC", - "author": "", - "main": "src/index.js", - "scripts": { - "check:type": "tsc", - "test:ci": "vitest run", - "test:watch": "vitest", - "type:tests": "tsc -p ./tests/tsconfig.json" - }, - "devDependencies": { - "@cloudflare/workers-tsconfig": "workspace:^", - "typescript": "catalog:default", - "undici": "catalog:default", - "vitest": "catalog:default", - "wrangler": "workspace:*" - }, - "volta": { - "extends": "../../package.json" - } -} diff --git a/fixtures/ai-app/src/index.js b/fixtures/ai-app/src/index.js deleted file mode 100644 index c2a4731b1163..000000000000 --- a/fixtures/ai-app/src/index.js +++ /dev/null @@ -1,13 +0,0 @@ -console.log("startup log"); - -export default { - async fetch(request, env) { - console.log("request log"); - - return Response.json({ - binding: env.AI, - run: typeof env.AI.run, - fetch: typeof env.AI.fetch, - }); - }, -}; diff --git a/fixtures/ai-app/tests/index.test.ts b/fixtures/ai-app/tests/index.test.ts deleted file mode 100644 index 5ecbd5744c93..000000000000 --- a/fixtures/ai-app/tests/index.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { resolve } from "path"; -import { fetch } from "undici"; -import { afterAll, beforeAll, describe, it } from "vitest"; -import { runWranglerDev } from "../../shared/src/run-wrangler-long-lived"; - -describe("'wrangler dev' correctly renders pages", () => { - let ip: string, - port: number, - stop: (() => Promise) | undefined, - getOutput: () => string; - - beforeAll(async () => { - ({ ip, port, stop, getOutput } = await runWranglerDev( - resolve(__dirname, ".."), - ["--local", "--port=0", "--inspector-port=0"] - )); - }); - - afterAll(async () => { - await stop?.(); - }); - - it("ai binding methods ", async ({ expect }) => { - const response = await fetch(`http://${ip}:${port}/`); - const content = await response.json(); - expect((content as Record).fetch).toEqual("function"); - expect((content as Record).run).toEqual("function"); - }); - - it("ai binding properties", async ({ expect }) => { - const response = await fetch(`http://${ip}:${port}/`); - const content = await response.json(); - expect((content as Record).binding).toEqual({ - aiGatewayLogId: null, - lastRequestHttpStatusCode: null, - lastRequestId: null, - lastRequestInternalStatusCode: null, - }); - }); -}); diff --git a/fixtures/ai-app/tests/tsconfig.json b/fixtures/ai-app/tests/tsconfig.json deleted file mode 100644 index be0dabdb19b9..000000000000 --- a/fixtures/ai-app/tests/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@cloudflare/workers-tsconfig/tsconfig.json", - "compilerOptions": { - "types": ["node"] - }, - "include": ["**/*.ts"] -} diff --git a/fixtures/ai-app/tsconfig.json b/fixtures/ai-app/tsconfig.json deleted file mode 100644 index 472714ec9e2c..000000000000 --- a/fixtures/ai-app/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "esModuleInterop": true, - "module": "CommonJS", - "lib": ["ES2020"], - "types": ["node"], - "skipLibCheck": true, - "moduleResolution": "node", - "noEmit": true - }, - "include": ["tests"] -} diff --git a/fixtures/ai-app/vitest.config.mts b/fixtures/ai-app/vitest.config.mts deleted file mode 100644 index 846cddc41995..000000000000 --- a/fixtures/ai-app/vitest.config.mts +++ /dev/null @@ -1,9 +0,0 @@ -import { defineProject, mergeConfig } from "vitest/config"; -import configShared from "../../vitest.shared"; - -export default mergeConfig( - configShared, - defineProject({ - test: {}, - }) -); diff --git a/fixtures/ai-app/wrangler.jsonc b/fixtures/ai-app/wrangler.jsonc deleted file mode 100644 index c697d31364a7..000000000000 --- a/fixtures/ai-app/wrangler.jsonc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "ai-app", - "compatibility_date": "2023-11-21", - "main": "src/index.js", - "ai": { - "binding": "AI", - }, -} diff --git a/fixtures/get-platform-proxy-remote-bindings/tests/index.test.ts b/fixtures/get-platform-proxy-remote-bindings/tests/index.test.ts index ed621f7267ea..7cc93607778e 100644 --- a/fixtures/get-platform-proxy-remote-bindings/tests/index.test.ts +++ b/fixtures/get-platform-proxy-remote-bindings/tests/index.test.ts @@ -92,14 +92,14 @@ if (auth) { { binding: "MY_WORKER", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, ], kv_namespaces: [ { binding: "MY_KV", id: remoteKvId, - experimental_remote: true, + remote: true, }, ], env: { @@ -108,14 +108,14 @@ if (auth) { { binding: "MY_WORKER", service: remoteStagingWorkerName, - experimental_remote: true, + remote: true, }, ], kv_namespaces: [ { binding: "MY_KV", id: remoteKvId, - experimental_remote: true, + remote: true, }, ], }, @@ -137,7 +137,6 @@ if (auth) { MY_KV: KVNamespace; }>({ configPath: "./.tmp/normal-usage/wrangler.json", - experimental: { remoteBindings: true }, }); const response = await fetchFromWorker(env.MY_WORKER, "OK"); @@ -160,7 +159,6 @@ if (auth) { MY_KV: KVNamespace; }>({ configPath: "./.tmp/normal-usage/wrangler.json", - experimental: { remoteBindings: true }, environment: "staging", }); @@ -183,6 +181,9 @@ if (auth) { MY_KV: KVNamespace; }>({ configPath: "./.tmp/normal-usage/wrangler.json", + experimental: { + remoteBindings: false, + }, }); const response = await fetchFromWorker( @@ -219,7 +220,7 @@ if (auth) { { binding: "MY_WORKER", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, ], }, @@ -233,7 +234,6 @@ if (auth) { MY_WORKER: Fetcher; }>({ configPath: "./.tmp/config-with-invalid-account-id/wrangler.json", - experimental: { remoteBindings: true }, }); const response = await fetchFromWorker(env.MY_WORKER, "OK", 10_000); @@ -257,7 +257,7 @@ if (auth) { { binding: "MY_WORKER", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, ], }, @@ -271,7 +271,6 @@ if (auth) { MY_WORKER: Fetcher; }>({ configPath: "./.tmp/config-with-no-account-id/wrangler.json", - experimental: { remoteBindings: true }, }); const response = await fetchFromWorker(env.MY_WORKER, "OK"); diff --git a/fixtures/vitest-pool-workers-examples/ai-vectorize/vitest.config.ts b/fixtures/vitest-pool-workers-examples/ai-vectorize/vitest.config.ts index 1e818114314e..01335d4d60b3 100644 --- a/fixtures/vitest-pool-workers-examples/ai-vectorize/vitest.config.ts +++ b/fixtures/vitest-pool-workers-examples/ai-vectorize/vitest.config.ts @@ -6,6 +6,7 @@ export default defineWorkersProject({ poolOptions: { workers: { singleWorker: true, + remoteBindings: false, wrangler: { configPath: "./wrangler.jsonc" }, }, }, diff --git a/fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.staging.ts b/fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.staging.ts index 3f2c76ec754a..597e89590521 100644 --- a/fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.staging.ts +++ b/fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.staging.ts @@ -15,7 +15,6 @@ export default defineWorkersConfig({ include: ["test-staging/**/*.spec.ts"], poolOptions: { workers: { - experimental_remoteBindings: true, wrangler: { configPath: "./wrangler.json", environment: "staging" }, }, }, diff --git a/fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.ts b/fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.ts index efd74027518f..0bd74ad25c15 100644 --- a/fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.ts +++ b/fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.ts @@ -15,7 +15,6 @@ export default defineWorkersConfig({ include: ["test/**/*.spec.ts"], poolOptions: { workers: { - experimental_remoteBindings: true, wrangler: { configPath: "./wrangler.json" }, }, }, diff --git a/fixtures/vitest-pool-workers-remote-bindings/wrangler.json b/fixtures/vitest-pool-workers-remote-bindings/wrangler.json index f74d6f974e4f..623a8b5b89cb 100644 --- a/fixtures/vitest-pool-workers-remote-bindings/wrangler.json +++ b/fixtures/vitest-pool-workers-remote-bindings/wrangler.json @@ -6,7 +6,7 @@ { "binding": "MY_WORKER", "service": "my-worker-test", - "experimental_remote": true + "remote": true } ], "env": { @@ -15,7 +15,7 @@ { "binding": "MY_WORKER", "service": "my-staging-worker-test", - "experimental_remote": true + "remote": true } ] } diff --git a/fixtures/worker-ts/wrangler.jsonc b/fixtures/worker-ts/wrangler.jsonc index e373588ae2c7..3744a97862a1 100644 --- a/fixtures/worker-ts/wrangler.jsonc +++ b/fixtures/worker-ts/wrangler.jsonc @@ -2,4 +2,10 @@ "name": "worker-ts", "main": "src/index.ts", "compatibility_date": "2023-05-04", + "hyperdrive": [ + { + "binding": "H", + "id": "hello", + }, + ], } diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/auxiliary-worker/wrangler.jsonc b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/auxiliary-worker/wrangler.jsonc index 0828c649d3e3..f9f7ea3d08ad 100644 --- a/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/auxiliary-worker/wrangler.jsonc +++ b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/auxiliary-worker/wrangler.jsonc @@ -7,7 +7,7 @@ { "binding": "REMOTE_WORKER", "service": "<>", - "experimental_remote": true, + "remote": true, }, ], } diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/entry-worker/wrangler.jsonc b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/entry-worker/wrangler.jsonc index 8f50be0cf240..fa0bbcec907a 100644 --- a/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/entry-worker/wrangler.jsonc +++ b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/entry-worker/wrangler.jsonc @@ -7,12 +7,12 @@ { "binding": "LOCAL_WORKER", "service": "cloudflare-vite-e2e-remote-bindings-auxiliary-worker", - "experimental_remote": false, + "remote": false, }, { "binding": "REMOTE_WORKER", "service": "<>", - "experimental_remote": true, + "remote": true, }, ], } diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/vite.config.ts b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/vite.config.ts index b5332290d77f..8f5a2895ddfc 100644 --- a/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/vite.config.ts +++ b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/vite.config.ts @@ -12,7 +12,6 @@ export default defineConfig({ ], inspectorPort: false, persistState: false, - experimental: { remoteBindings: true }, }), ], }); diff --git a/packages/vite-plugin-cloudflare/src/miniflare-options.ts b/packages/vite-plugin-cloudflare/src/miniflare-options.ts index 8fd373881cb3..fa26bd76bc31 100644 --- a/packages/vite-plugin-cloudflare/src/miniflare-options.ts +++ b/packages/vite-plugin-cloudflare/src/miniflare-options.ts @@ -15,7 +15,7 @@ import colors from "picocolors"; import { globSync } from "tinyglobby"; import * as vite from "vite"; import { - experimental_maybeStartOrUpdateRemoteProxySession, + maybeStartOrUpdateRemoteProxySession, unstable_convertConfigBindingsToStartWorkerBindings, unstable_getMiniflareWorkerOptions, } from "wrangler"; @@ -41,9 +41,9 @@ import type { import type { MiniflareOptions, WorkerOptions } from "miniflare"; import type { FetchFunctionOptions } from "vite/module-runner"; import type { - Experimental_RemoteProxySession, + Binding, + RemoteProxySession, SourcelessWorkerOptions, - Unstable_Binding, } from "wrangler"; function getPersistenceRoot( @@ -230,8 +230,8 @@ function logUnknownTails( const remoteProxySessionsDataMap = new Map< string, { - session: Experimental_RemoteProxySession; - remoteBindings: Record; + session: RemoteProxySession; + remoteBindings: Record; } | null >(); @@ -396,16 +396,16 @@ export async function getDevMiniflareOptions(config: { ? remoteProxySessionsDataMap.get(workerConfig.configPath) : undefined; - const remoteProxySessionData = resolvedPluginConfig.experimental - .remoteBindings - ? await experimental_maybeStartOrUpdateRemoteProxySession( - { - name: workerConfig.name, - bindings: bindings ?? {}, - }, - preExistingRemoteProxySession ?? null - ) - : undefined; + const remoteProxySessionData = + resolvedPluginConfig.experimental.remoteBindings ?? true + ? await maybeStartOrUpdateRemoteProxySession( + { + name: workerConfig.name, + bindings: bindings ?? {}, + }, + preExistingRemoteProxySession ?? null + ) + : undefined; if (workerConfig.configPath && remoteProxySessionData) { remoteProxySessionsDataMap.set( @@ -425,7 +425,7 @@ export async function getDevMiniflareOptions(config: { remoteProxySessionData?.session ?.remoteProxyConnectionString, remoteBindingsEnabled: - resolvedPluginConfig.experimental.remoteBindings, + resolvedPluginConfig.experimental.remoteBindings ?? true, containerBuildId, } ); @@ -726,16 +726,16 @@ export async function getPreviewMiniflareOptions(config: { ? remoteProxySessionsDataMap.get(workerConfig.configPath) : undefined; - const remoteProxySessionData = resolvedPluginConfig.experimental - .remoteBindings - ? await experimental_maybeStartOrUpdateRemoteProxySession( - { - name: workerConfig.name, - bindings: bindings ?? {}, - }, - preExistingRemoteProxySessionData ?? null - ) - : undefined; + const remoteProxySessionData = + resolvedPluginConfig.experimental.remoteBindings ?? true + ? await maybeStartOrUpdateRemoteProxySession( + { + name: workerConfig.name, + bindings: bindings ?? {}, + }, + preExistingRemoteProxySessionData ?? null + ) + : undefined; if (workerConfig.configPath && remoteProxySessionData) { remoteProxySessionsDataMap.set( @@ -751,7 +751,7 @@ export async function getPreviewMiniflareOptions(config: { remoteProxyConnectionString: remoteProxySessionData?.session?.remoteProxyConnectionString, remoteBindingsEnabled: - resolvedPluginConfig.experimental.remoteBindings, + resolvedPluginConfig.experimental.remoteBindings ?? true, containerBuildId, } ); diff --git a/packages/vitest-pool-workers/src/pool/config.ts b/packages/vitest-pool-workers/src/pool/config.ts index 798f6f7d043f..5fc8960554fa 100644 --- a/packages/vitest-pool-workers/src/pool/config.ts +++ b/packages/vitest-pool-workers/src/pool/config.ts @@ -13,10 +13,7 @@ import { getProjectPath, getRelativeProjectPath } from "./helpers"; import type { ModuleRule, WorkerOptions } from "miniflare"; import type { ProvidedContext } from "vitest"; import type { WorkspaceProject } from "vitest/node"; -import type { - Experimental_RemoteProxySession, - Unstable_Binding, -} from "wrangler"; +import type { Binding, RemoteProxySession } from "wrangler"; import type { ParseParams, ZodError } from "zod"; export interface WorkersConfigPluginAPI { @@ -48,10 +45,10 @@ const WorkersPoolOptionsSchema = z.object({ */ isolatedStorage: z.boolean().default(true), /** - * Enables experimental remote bindings to access remote resources configured - * with `experimental_experimental_remote: true` in the wrangler configuration file. + * Enables remote bindings to access remote resources configured + * with `remote: true` in the wrangler configuration file. */ - experimental_remoteBindings: z.boolean().optional(), + remoteBindings: z.boolean().default(true), /** * Runs all tests in this project serially in the same worker, using the same * module cache. This can significantly speed up tests if you've got lots of @@ -184,8 +181,8 @@ function filterTails( const remoteProxySessionsDataMap = new Map< string, { - session: Experimental_RemoteProxySession; - remoteBindings: Record; + session: RemoteProxySession; + remoteBindings: Record; } | null >(); @@ -257,15 +254,16 @@ async function parseCustomPoolOptions( ? remoteProxySessionsDataMap.get(options.wrangler.configPath) : undefined; - const remoteProxySessionData = options.experimental_remoteBindings - ? await wrangler.experimental_maybeStartOrUpdateRemoteProxySession( - { - path: options.wrangler.configPath, - environment: options.wrangler.environment, - }, - preExistingRemoteProxySessionData ?? null - ) - : null; + const remoteProxySessionData = + options.remoteBindings ?? true + ? await wrangler.maybeStartOrUpdateRemoteProxySession( + { + path: options.wrangler.configPath, + environment: options.wrangler.environment, + }, + preExistingRemoteProxySessionData ?? null + ) + : null; if (options.wrangler?.configPath && remoteProxySessionData) { remoteProxySessionsDataMap.set( @@ -285,7 +283,7 @@ async function parseCustomPoolOptions( // doesn't work with containers yet so let's just disable it enableContainers: false, }, - remoteBindingsEnabled: options.experimental_remoteBindings, + remoteBindingsEnabled: options.remoteBindings ?? true, remoteProxyConnectionString: remoteProxySessionData?.session?.remoteProxyConnectionString, } diff --git a/packages/vitest-pool-workers/test/bindings.test.ts b/packages/vitest-pool-workers/test/bindings.test.ts index 3ca937514962..8714352288f0 100644 --- a/packages/vitest-pool-workers/test/bindings.test.ts +++ b/packages/vitest-pool-workers/test/bindings.test.ts @@ -18,6 +18,7 @@ test("hello_world support", async ({ expect, seed, vitestRun }) => { `, "wrangler.jsonc": dedent` { + "name": "test-worker", "compatibility_date": "2025-01-01", "unsafe_hello_world": [ { @@ -56,5 +57,6 @@ test("hello_world support", async ({ expect, seed, vitestRun }) => { }); const result = await vitestRun(); + await expect(result.exitCode).resolves.toBe(0); }); diff --git a/packages/wrangler/e2e/dev-with-resources.test.ts b/packages/wrangler/e2e/dev-with-resources.test.ts index 6e207a983bea..d9963fd2517c 100644 --- a/packages/wrangler/e2e/dev-with-resources.test.ts +++ b/packages/wrangler/e2e/dev-with-resources.test.ts @@ -622,7 +622,7 @@ describe.sequential.each(RUNTIMES)("Bindings: $flags", ({ runtime, flags }) => { // Refer to https://github.com/cloudflare/workers-sdk/pull/8492 for full context on why this test does different things to the others. // In particular, it uses a shared resource across test runs - it.skipIf(!CLOUDFLARE_ACCOUNT_ID)("exposes Vectorize bindings", async () => { + it.skipIf(isLocal)("exposes Vectorize bindings", async () => { const name = await helper.vectorize( 32, "euclidean", @@ -675,7 +675,7 @@ describe.sequential.each(RUNTIMES)("Bindings: $flags", ({ runtime, flags }) => { }); const worker = helper.runLongLived( - `wrangler dev ${flags} --port ${port} --inspector-port ${inspectorPort} --experimental-vectorize-bind-to-prod` + `wrangler dev ${flags} --port ${port} --inspector-port ${inspectorPort}` ); const { url } = await worker.waitForReady(); await fetch(`${url}/insert`); diff --git a/packages/wrangler/e2e/remote-binding/dev-remote-bindings.test.ts b/packages/wrangler/e2e/remote-binding/dev-remote-bindings.test.ts index fb100379d252..a70ea7e7d961 100644 --- a/packages/wrangler/e2e/remote-binding/dev-remote-bindings.test.ts +++ b/packages/wrangler/e2e/remote-binding/dev-remote-bindings.test.ts @@ -49,13 +49,13 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( { binding: "REMOTE_WORKER", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, ], }), }); - const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); + const worker = helper.runLongLived("wrangler dev"); const { url } = await worker.waitForReady(); @@ -77,13 +77,13 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( { binding: "REMOTE_WORKER", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, ], }), }); - const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); + const worker = helper.runLongLived("wrangler dev"); const { url } = await worker.waitForReady(); @@ -139,7 +139,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( }), }); - const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); + const worker = helper.runLongLived("wrangler dev"); const { url } = await worker.waitForReady(); @@ -163,7 +163,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( }), }); - const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); + const worker = helper.runLongLived("wrangler dev"); const { url } = await worker.waitForReady(); @@ -177,7 +177,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( Your Worker has access to the following bindings: Binding Resource Mode env.AI AI remote - ▲ [WARNING] AI bindings always access remote resources, and so may incur usage charges even in local dev. To suppress this warning, set \`experimental_remote: true\` for the binding definition in your configuration file. + ▲ [WARNING] AI bindings always access remote resources, and so may incur usage charges even in local dev. To suppress this warning, set \`remote: true\` for the binding definition in your configuration file. ⎔ Starting local server... [wrangler:info] Ready on http://: [wrangler:info] GET / 200 OK (TIMINGS)`; @@ -186,7 +186,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( Your Worker has access to the following bindings: Binding Resource Mode env.AI AI remote - ▲ [WARNING] AI bindings always access remote resources, and so may incur usage charges even in local dev. To suppress this warning, set \`experimental_remote: true\` for the binding definition in your configuration file. + ▲ [WARNING] AI bindings always access remote resources, and so may incur usage charges even in local dev. To suppress this warning, set \`remote: true\` for the binding definition in your configuration file. ⎔ Starting local server... [wrangler:info] Ready on http://: [wrangler:info] GET / 200 OK (TIMINGS)`; @@ -209,13 +209,13 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( { binding: "REMOTE_WORKER", service: "non-existent-service-binding", - experimental_remote: true, + remote: true, }, ], }), }); - const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); + const worker = helper.runLongLived("wrangler dev"); await worker.waitForReady(); @@ -238,13 +238,13 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( { binding: "KV_BINDING", id: "non-existent-kv", - experimental_remote: true, + remote: true, }, ], }), }); - const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); + const worker = helper.runLongLived("wrangler dev"); await worker.waitForReady(); @@ -274,7 +274,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( { binding: "REMOTE_WORKER", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, ], }), @@ -290,7 +290,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( // Note: we use the same binding name but bound to a difference service binding: "REMOTE_WORKER", service: alternativeRemoteWorkerName, - experimental_remote: true, + remote: true, }, ], }), @@ -304,7 +304,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( }); const worker = helper.runLongLived( - `wrangler dev --x-remote-bindings -c wrangler.json -c ${localTest}/wrangler.json` + `wrangler dev -c wrangler.json -c ${localTest}/wrangler.json` ); const { url } = await worker.waitForReady(); diff --git a/packages/wrangler/e2e/remote-binding/miniflare-remote-resources.test.ts b/packages/wrangler/e2e/remote-binding/miniflare-remote-resources.test.ts index 996dd50c88de..fca1b5174f16 100644 --- a/packages/wrangler/e2e/remote-binding/miniflare-remote-resources.test.ts +++ b/packages/wrangler/e2e/remote-binding/miniflare-remote-resources.test.ts @@ -498,8 +498,7 @@ async function runTestCase( helper: WranglerE2ETestHelper, { disableRemoteBindings } = { disableRemoteBindings: false } ) { - const { experimental_startRemoteProxySession } = - await helper.importWrangler(); + const { startRemoteProxySession } = await helper.importWrangler(); const { Miniflare } = await helper.importMiniflare(); await helper.seed(path.resolve(__dirname, "./workers")); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion @@ -510,7 +509,7 @@ async function runTestCase( ? testCase.remoteProxySessionConfig(setupResult) : testCase.remoteProxySessionConfig; - const remoteProxySession = await experimental_startRemoteProxySession( + const remoteProxySession = await startRemoteProxySession( ...remoteProxySessionConfig ); diff --git a/packages/wrangler/e2e/remote-binding/remote-bindings-api.test.ts b/packages/wrangler/e2e/remote-binding/remote-bindings-api.test.ts index aeac42279d3d..cf14cd731164 100644 --- a/packages/wrangler/e2e/remote-binding/remote-bindings-api.test.ts +++ b/packages/wrangler/e2e/remote-binding/remote-bindings-api.test.ts @@ -24,8 +24,8 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( const { Miniflare } = await helper.importMiniflare(); const { - experimental_startRemoteProxySession: startRemoteProxySession, - experimental_maybeStartOrUpdateRemoteProxySession: + startRemoteProxySession: startRemoteProxySession, + maybeStartOrUpdateRemoteProxySession: maybeStartOrUpdateRemoteProxySession, } = await helper.importWrangler(); @@ -158,7 +158,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( MY_SERVICE: { type: "service", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, }, }); @@ -189,7 +189,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( MY_SERVICE: { type: "service", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, }, }, @@ -222,7 +222,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( MY_SERVICE: { type: "service", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, }, }, diff --git a/packages/wrangler/e2e/remote-binding/start-worker-remote-bindings.test.ts b/packages/wrangler/e2e/remote-binding/start-worker-remote-bindings.test.ts index 6b0379508976..2097bef0f24a 100644 --- a/packages/wrangler/e2e/remote-binding/start-worker-remote-bindings.test.ts +++ b/packages/wrangler/e2e/remote-binding/start-worker-remote-bindings.test.ts @@ -42,7 +42,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)("startWorker - remote bindings", () => { { binding: "REMOTE_WORKER", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, ], }), @@ -75,7 +75,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)("startWorker - remote bindings", () => { { binding: "REMOTE_WORKER", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, ], }), diff --git a/packages/wrangler/e2e/remote-binding/wrangler-remote-resources.test.ts b/packages/wrangler/e2e/remote-binding/wrangler-remote-resources.test.ts index 449863fc6c46..634edd01039b 100644 --- a/packages/wrangler/e2e/remote-binding/wrangler-remote-resources.test.ts +++ b/packages/wrangler/e2e/remote-binding/wrangler-remote-resources.test.ts @@ -1,6 +1,5 @@ import assert from "node:assert"; import path from "node:path"; -import { setTimeout } from "node:timers/promises"; import dedent from "ts-dedent"; import { fetch } from "undici"; import { @@ -89,13 +88,13 @@ const testCases: TestCase>[] = [ { binding: "SERVICE", service: targetWorkerName, - experimental_remote: true, + remote: true, }, { binding: "SERVICE_WITH_ENTRYPOINT", service: targetWorkerName, entrypoint: "CustomEntrypoint", - experimental_remote: true, + remote: true, }, ], }), @@ -115,7 +114,7 @@ const testCases: TestCase>[] = [ compatibility_date: "2025-01-01", ai: { binding: "AI", - experimental_remote: true, + remote: true, }, }), expectedResponseMatch: expect.stringMatching( @@ -132,7 +131,7 @@ const testCases: TestCase>[] = [ compatibility_date: "2025-01-01", browser: { binding: "BROWSER", - experimental_remote: true, + remote: true, }, }), expectedResponseMatch: expect.stringMatching(/sessionId/), @@ -146,7 +145,7 @@ const testCases: TestCase>[] = [ compatibility_date: "2025-01-01", images: { binding: "IMAGES", - experimental_remote: true, + remote: true, }, }), expectedResponseMatch: expect.stringMatching("image/avif"), @@ -171,7 +170,7 @@ const testCases: TestCase>[] = [ { binding: "VECTORIZE_BINDING", index_name: name, - experimental_remote: true, + remote: true, }, ], }), @@ -210,7 +209,7 @@ const testCases: TestCase>[] = [ { binding: "DISPATCH", namespace: namespace, - experimental_remote: true, + remote: true, }, ], }), @@ -238,7 +237,7 @@ const testCases: TestCase>[] = [ { binding: "KV_BINDING", id: namespaceId, - experimental_remote: true, + remote: true, }, ], }), @@ -269,7 +268,7 @@ const testCases: TestCase>[] = [ { binding: "R2_BINDING", bucket_name: bucketName, - experimental_remote: true, + remote: true, }, ], }), @@ -301,7 +300,7 @@ const testCases: TestCase>[] = [ binding: "DB", database_id: id, database_name: name, - experimental_remote: true, + remote: true, }, ], }), @@ -362,7 +361,7 @@ const testCases: TestCase>[] = [ { binding: "MTLS", certificate_id: certificateId, - experimental_remote: true, + remote: true, }, ], }), @@ -379,7 +378,7 @@ const testCases: TestCase>[] = [ { binding: "PIPELINE", pipeline: "preserve-e2e-pipelines", - experimental_remote: true, + remote: true, }, ], }), @@ -396,7 +395,7 @@ const testCases: TestCase>[] = [ send_email: [ { name: "EMAIL", - experimental_remote: true, + remote: true, }, ], }), @@ -427,7 +426,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( await writeWranglerConfig(testCase, helper, workerName); - const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); + const worker = helper.runLongLived("wrangler dev"); const { url } = await worker.waitForReady(); @@ -440,33 +439,6 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( ); } }); - - it.skipIf(testCase.worksWithoutRemoteBindings)( - "fails when remote bindings is disabled", - // Turn off retries because this test is expected to fail - { retry: 0, fails: true }, - async () => { - await helper.seed(path.resolve(__dirname, "./workers")); - - await writeWranglerConfig(testCase, helper, workerName); - - const worker = helper.runLongLived("wrangler dev"); - - const { url } = await worker.waitForReady(); - - const response = await fetchText(url); - expect(response).toEqual(testCase.expectedResponseMatch); - - // Wait for async logging (e.g. pipeline messages received) - await setTimeout(1_000); - - if (testCase.expectedOutputMatch) { - expect(await worker.currentOutput).toEqual( - testCase.expectedOutputMatch - ); - } - } - ); }); describe.sequential( @@ -497,7 +469,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( "export default { fetch() { return new Response('Ready to start tests') } }", }); - worker = helper.runLongLived("wrangler dev --x-remote-bindings", { + worker = helper.runLongLived("wrangler dev", { stopOnTestFinished: false, }); @@ -560,7 +532,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( { binding: "KV_REMOTE_BINDING", id: kvId, - experimental_remote: true, + remote: true, }, ], }, @@ -569,7 +541,7 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( ), }); - const worker = helper.runLongLived("wrangler dev --x-remote-bindings", { + const worker = helper.runLongLived("wrangler dev", { stopOnTestFinished: false, }); @@ -619,13 +591,13 @@ describe.skipIf(!CLOUDFLARE_ACCOUNT_ID)( { binding: "REMOTE_WORKER", service: remoteWorkerName, - experimental_remote: true, + remote: true, }, ], }), }); - const worker = helper.runLongLived("wrangler dev --x-remote-bindings", { + const worker = helper.runLongLived("wrangler dev", { env: { ...process.env, CLOUDFLARE_ACCOUNT_ID: undefined, diff --git a/packages/wrangler/e2e/start-worker-auth-opts.test.ts b/packages/wrangler/e2e/start-worker-auth-opts.test.ts index ba3f270fb485..5048299cce38 100644 --- a/packages/wrangler/e2e/start-worker-auth-opts.test.ts +++ b/packages/wrangler/e2e/start-worker-auth-opts.test.ts @@ -68,11 +68,10 @@ describe("startWorker - auth options", () => { bindings: { AI: { type: "ai", - experimental_remote: true, + remote: true, }, }, dev: { - experimentalRemoteBindings: true, auth: validAuth, }, }); @@ -94,7 +93,6 @@ describe("startWorker - auth options", () => { await worker.patchConfig({ dev: { - experimentalRemoteBindings: true, auth: incorrectAuth, }, }); @@ -121,11 +119,10 @@ describe("startWorker - auth options", () => { bindings: { AI: { type: "ai", - experimental_remote: true, + remote: true, }, }, dev: { - experimentalRemoteBindings: true, auth: incorrectAuth, }, }); @@ -149,7 +146,6 @@ describe("startWorker - auth options", () => { await worker.patchConfig({ dev: { - experimentalRemoteBindings: true, auth: validAuth, }, }); @@ -222,7 +218,6 @@ describe("startWorker - auth options", () => { const worker = await startWorker({ entrypoint: path.resolve(helper.tmpPath, "src/index.js"), dev: { - experimentalRemoteBindings: true, auth: someAuth, }, }); diff --git a/packages/wrangler/src/__tests__/dev.test.ts b/packages/wrangler/src/__tests__/dev.test.ts index 645630880925..39e61817ea9d 100644 --- a/packages/wrangler/src/__tests__/dev.test.ts +++ b/packages/wrangler/src/__tests__/dev.test.ts @@ -2077,89 +2077,6 @@ describe.sequential("wrangler dev", () => { ); }); - describe("remote bindings", () => { - const wranglerConfigWithRemoteBindings = { - services: [ - { binding: "WorkerA", service: "A", experimental_remote: true }, - ], - kv_namespaces: [ - { - binding: "KV", - id: "xxxx-xxxx-xxxx-xxxx", - experimental_remote: true, - }, - ], - r2_buckets: [ - { - binding: "MY_R2", - bucket_name: "my-bucket", - experimental_remote: true, - }, - ], - queues: { - producers: [ - { - binding: "MY_QUEUE_PRODUCES", - queue: "my-queue", - experimental_remote: true, - }, - ], - }, - d1_databases: [ - { - binding: "MY_D1", - database_id: "xxx", - experimental_remote: true, - }, - ], - workflows: [ - { - binding: "MY_WORKFLOW", - name: "workflow-name", - class_name: "myClass", - experimental_remote: true, - }, - ], - }; - - it("should ignore remote true settings without the --x-remote-bindings flag (initial logs only test)", async () => { - writeWranglerConfig(wranglerConfigWithRemoteBindings); - fs.writeFileSync("index.js", `export default {};`); - await runWranglerUntilConfig("dev index.js"); - expect(std.out).toMatchInlineSnapshot(` - "Your Worker has access to the following bindings: - Binding Resource Mode - env.MY_WORKFLOW (myClass) Workflow local - env.KV (xxxx-xxxx-xxxx-xxxx) KV Namespace local - env.MY_QUEUE_PRODUCES (my-queue) Queue local - env.MY_D1 (xxx) D1 Database local - env.MY_R2 (my-bucket) R2 Bucket local - env.WorkerA (A) Worker local [not connected] - - " - `); - }); - - it("should honor the remote true settings with the --x-remote-bindings flag (initial logs only test)", async () => { - writeWranglerConfig(wranglerConfigWithRemoteBindings); - fs.writeFileSync("index.js", `export default {};`); - await runWranglerUntilConfig("dev --x-remote-bindings index.js"); - expect(std.out).toMatchInlineSnapshot(` - "Your Worker has access to the following bindings: - Binding Resource Mode - env.MY_WORKFLOW (myClass) Workflow local - env.KV (xxxx-xxxx-xxxx-xxxx) KV Namespace remote - env.MY_QUEUE_PRODUCES (my-queue) Queue remote - env.MY_D1 (xxx) D1 Database remote - env.MY_R2 (my-bucket) R2 Bucket remote - env.WorkerA (A) Worker remote - - " - `); - expect(std.warn).toMatchInlineSnapshot(`""`); - }); - }); - describe("containers", () => { const containerConfig = { main: "index.js", diff --git a/packages/wrangler/src/__tests__/experimental-commands-api.test.ts b/packages/wrangler/src/__tests__/experimental-commands-api.test.ts index b6f2f62dfdaa..6be37284ac20 100644 --- a/packages/wrangler/src/__tests__/experimental-commands-api.test.ts +++ b/packages/wrangler/src/__tests__/experimental-commands-api.test.ts @@ -42,6 +42,7 @@ describe("experimental_getWranglerCommands", () => { "alias": Array [ "x-remote-bindings", ], + "default": true, "describe": "Experimental: Enable Remote Bindings", "hidden": true, "type": "boolean", diff --git a/packages/wrangler/src/__tests__/metrics.test.ts b/packages/wrangler/src/__tests__/metrics.test.ts index 25ec24810c59..81432cc36ef1 100644 --- a/packages/wrangler/src/__tests__/metrics.test.ts +++ b/packages/wrangler/src/__tests__/metrics.test.ts @@ -197,6 +197,7 @@ describe("metrics", () => { argsCombination: "", command: "wrangler docs", args: { + xRemoteBindings: true, search: [""], }, }; diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index 980068532717..2d6d9134e287 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -748,7 +748,7 @@ describe("wrangler workflows", () => { name: "my-workflow", class_name: "MyWorkflow", script_name: "external-script", - experimental_remote: true, + remote: true, }, ], }); diff --git a/packages/wrangler/src/api/dev.ts b/packages/wrangler/src/api/dev.ts index 4a35dd6d1950..8c6d0c68a19f 100644 --- a/packages/wrangler/src/api/dev.ts +++ b/packages/wrangler/src/api/dev.ts @@ -222,7 +222,7 @@ export async function unstable_dev( logLevel: options?.logLevel ?? defaultLogLevel, port: options?.port ?? 0, experimentalProvision: undefined, - experimentalRemoteBindings: false, + experimentalRemoteBindings: true, experimentalVectorizeBindToProd: vectorizeBindToProd ?? false, experimentalImagesLocalMode: imagesLocalMode ?? false, enableIpc: options?.experimental?.enableIpc, diff --git a/packages/wrangler/src/api/integrations/platform/index.ts b/packages/wrangler/src/api/integrations/platform/index.ts index 3e732b0f36ca..23bc296a5630 100644 --- a/packages/wrangler/src/api/integrations/platform/index.ts +++ b/packages/wrangler/src/api/integrations/platform/index.ts @@ -133,7 +133,8 @@ export async function getPlatformProxy< >( options: GetPlatformProxyOptions = {} ): Promise> { - const experimentalRemoteBindings = !!options.experimental?.remoteBindings; + const experimentalRemoteBindings = + options.experimental?.remoteBindings ?? true; const env = options.environment; @@ -429,10 +430,7 @@ export function unstable_getMiniflareWorkerOptions( bindings.services.map((binding) => { const name = binding.service === config.name ? kCurrentWorker : binding.service; - if ( - options?.remoteProxyConnectionString && - binding.experimental_remote - ) { + if (options?.remoteProxyConnectionString && binding.remote) { return [ binding.binding, { diff --git a/packages/wrangler/src/api/remoteBindings/index.ts b/packages/wrangler/src/api/remoteBindings/index.ts index b516fdc01570..8e963ae96ffb 100644 --- a/packages/wrangler/src/api/remoteBindings/index.ts +++ b/packages/wrangler/src/api/remoteBindings/index.ts @@ -100,7 +100,7 @@ export function pickRemoteBindings( return true; } - return "experimental_remote" in binding && binding["experimental_remote"]; + return "remote" in binding && binding["remote"]; }) ); } @@ -152,10 +152,8 @@ export async function maybeStartOrUpdateRemoteProxySession( env: wranglerConfigObject.environment, }); - assert(config.name); - wranglerOrWorkerConfigObject = { - name: config.name, + name: config.name ?? "worker", complianceRegion: getCloudflareComplianceRegion(config), bindings: convertConfigBindingsToStartWorkerBindings(config) ?? {}, }; diff --git a/packages/wrangler/src/api/startDevWorker/ConfigController.ts b/packages/wrangler/src/api/startDevWorker/ConfigController.ts index 60ef7d8f6e7d..0a57140de1af 100644 --- a/packages/wrangler/src/api/startDevWorker/ConfigController.ts +++ b/packages/wrangler/src/api/startDevWorker/ConfigController.ts @@ -159,7 +159,9 @@ async function resolveDevConfig( multiworkerPrimary: input.dev?.multiworkerPrimary, imagesLocalMode: input.dev?.imagesLocalMode ?? false, experimentalRemoteBindings: - input.dev?.experimentalRemoteBindings ?? getFlag("REMOTE_BINDINGS"), + input.dev?.experimentalRemoteBindings ?? + getFlag("REMOTE_BINDINGS") ?? + true, enableContainers: input.dev?.enableContainers ?? config.dev.enable_containers, dockerPath: input.dev?.dockerPath ?? getDockerPath(), @@ -206,7 +208,7 @@ async function resolveBindings( input.bindings )?.[0], }, - input.dev?.experimentalRemoteBindings + input.dev?.experimentalRemoteBindings ?? true ); // Create a print function that captures the current bindings context diff --git a/packages/wrangler/src/api/startDevWorker/LocalRuntimeController.ts b/packages/wrangler/src/api/startDevWorker/LocalRuntimeController.ts index 28b05fdc65c9..7b2baabec4d8 100644 --- a/packages/wrangler/src/api/startDevWorker/LocalRuntimeController.ts +++ b/packages/wrangler/src/api/startDevWorker/LocalRuntimeController.ts @@ -204,7 +204,7 @@ export class LocalRuntimeController extends RuntimeController { const configBundle = await convertToConfigBundle(data); const experimentalRemoteBindings = - data.config.dev.experimentalRemoteBindings ?? false; + data.config.dev.experimentalRemoteBindings ?? true; if (experimentalRemoteBindings && !data.config.dev?.remote) { // note: remote bindings use (transitively) LocalRuntimeController, so we need to import diff --git a/packages/wrangler/src/api/startDevWorker/MultiworkerRuntimeController.ts b/packages/wrangler/src/api/startDevWorker/MultiworkerRuntimeController.ts index 87bdcf2f00eb..2232399d3a2e 100644 --- a/packages/wrangler/src/api/startDevWorker/MultiworkerRuntimeController.ts +++ b/packages/wrangler/src/api/startDevWorker/MultiworkerRuntimeController.ts @@ -113,7 +113,7 @@ export class MultiworkerRuntimeController extends LocalRuntimeController { const configBundle = await convertToConfigBundle(data); const experimentalRemoteBindings = - data.config.dev.experimentalRemoteBindings; + data.config.dev.experimentalRemoteBindings ?? true; if (experimentalRemoteBindings && !data.config.dev?.remote) { // note: remote bindings use (transitively) LocalRuntimeController, so we need to import diff --git a/packages/wrangler/src/api/startDevWorker/types.ts b/packages/wrangler/src/api/startDevWorker/types.ts index 1504efbe4424..f000f90f0d29 100644 --- a/packages/wrangler/src/api/startDevWorker/types.ts +++ b/packages/wrangler/src/api/startDevWorker/types.ts @@ -163,7 +163,7 @@ export interface StartDevWorkerInput { /** Whether a script tag is inserted on text/html responses which will reload the page upon file changes. Defaults to false. */ liveReload?: boolean; - /** The local address to reach your worker. Applies to experimental_remote: true (remote mode) and remote: false (local mode). */ + /** The local address to reach your worker. Applies to remote: true (remote mode) and remote: false (local mode). */ server?: { hostname?: string; // --ip port?: number; // --port diff --git a/packages/wrangler/src/cli.ts b/packages/wrangler/src/cli.ts index bb2103fa75ba..593cedc75f67 100644 --- a/packages/wrangler/src/cli.ts +++ b/packages/wrangler/src/cli.ts @@ -66,12 +66,11 @@ export { export { experimental_patchConfig } from "./config/patch-config"; export { - startRemoteProxySession as experimental_startRemoteProxySession, - type StartRemoteProxySessionOptions as experimental_StartRemoteProxySessionOptions, - maybeStartOrUpdateRemoteProxySession as experimental_maybeStartOrUpdateRemoteProxySession, - pickRemoteBindings as experimental_pickRemoteBindings, - type Binding as Unstable_Binding, - type RemoteProxySession as Experimental_RemoteProxySession, + startRemoteProxySession, + type StartRemoteProxySessionOptions, + maybeStartOrUpdateRemoteProxySession, + type Binding, + type RemoteProxySession, convertConfigBindingsToStartWorkerBindings as unstable_convertConfigBindingsToStartWorkerBindings, } from "./api"; diff --git a/packages/wrangler/src/config/environment.ts b/packages/wrangler/src/config/environment.ts index 1f1f37c8ce1c..4268a6544bd3 100644 --- a/packages/wrangler/src/config/environment.ts +++ b/packages/wrangler/src/config/environment.ts @@ -593,8 +593,8 @@ export type WorkflowBinding = { class_name: string; /** The script where the Workflow is defined (if it's external to this Worker) */ script_name?: string; - /** Whether the Workflow should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the Workflow should be remote or not */ + remote?: boolean; }; /** @@ -701,8 +701,8 @@ export interface EnvironmentNonInheritable { id?: string; /** The ID of the KV namespace used during `wrangler dev` */ preview_id?: string; - /** Whether the KV namespace should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the KV namespace should be remote or not */ + remote?: boolean; }[]; /** @@ -723,8 +723,8 @@ export interface EnvironmentNonInheritable { destination_address?: string; /** If this binding should be restricted to a set of verified addresses */ allowed_destination_addresses?: string[]; - /** Whether the binding should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the binding should be remote or not */ + remote?: boolean; }[]; /** @@ -750,8 +750,8 @@ export interface EnvironmentNonInheritable { /** The number of seconds to wait before delivering a message */ delivery_delay?: number; - /** Whether the Queue producer should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the Queue producer should be remote or not */ + remote?: boolean; }[]; /** Consumer configuration */ @@ -805,8 +805,8 @@ export interface EnvironmentNonInheritable { preview_bucket_name?: string; /** The jurisdiction that the bucket exists in. Default if not present. */ jurisdiction?: string; - /** Whether the R2 bucket should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the R2 bucket should be remote or not */ + remote?: boolean; }[]; /** @@ -835,8 +835,8 @@ export interface EnvironmentNonInheritable { migrations_dir?: string; /** Internal use only. */ database_internal_env?: string; - /** Whether the D1 database should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the D1 database should be remote or not */ + remote?: boolean; }[]; /** @@ -855,8 +855,8 @@ export interface EnvironmentNonInheritable { binding: string; /** The name of the index. */ index_name: string; - /** Whether the Vectorize index should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the Vectorize index should be remote or not */ + remote?: boolean; }[]; /** @@ -911,8 +911,8 @@ export interface EnvironmentNonInheritable { entrypoint?: string; /** Optional properties that will be made available to the service via ctx.props. */ props?: Record; - /** Whether the service binding should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the service binding should be remote or not */ + remote?: boolean; }[] | undefined; @@ -948,8 +948,8 @@ export interface EnvironmentNonInheritable { browser: | { binding: string; - /** Whether the Browser binding should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the Browser binding should be remote or not */ + remote?: boolean; } | undefined; @@ -968,8 +968,8 @@ export interface EnvironmentNonInheritable { | { binding: string; staging?: boolean; - /** Whether the AI binding should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the AI binding should be remote or not */ + remote?: boolean; } | undefined; @@ -987,8 +987,8 @@ export interface EnvironmentNonInheritable { images: | { binding: string; - /** Whether the Images binding should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the Images binding should be remote or not */ + remote?: boolean; } | undefined; @@ -1058,8 +1058,8 @@ export interface EnvironmentNonInheritable { binding: string; /** The uuid of the uploaded mTLS certificate */ certificate_id: string; - /** Whether the mtls fetcher should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the mtls fetcher should be remote or not */ + remote?: boolean; }[]; /** @@ -1091,8 +1091,8 @@ export interface EnvironmentNonInheritable { namespace: string; /** Details about the outbound Worker which will handle outbound requests from your namespace */ outbound?: DispatchNamespaceOutbound; - /** Whether the Dispatch Namespace should be remote or not (only available under `--x-remote-bindings`) */ - experimental_remote?: boolean; + /** Whether the Dispatch Namespace should be remote or not */ + remote?: boolean; }[]; /** diff --git a/packages/wrangler/src/config/validation.ts b/packages/wrangler/src/config/validation.ts index bc9b479ff60a..6788dcbf2f61 100644 --- a/packages/wrangler/src/config/validation.ts +++ b/packages/wrangler/src/config/validation.ts @@ -2055,9 +2055,9 @@ const validateWorkflowBinding: ValidatorFn = (diagnostics, field, value) => { isValid = false; } - if (!isOptionalProperty(value, "experimental_remote", "boolean")) { + if (!isOptionalProperty(value, "remote", "boolean")) { diagnostics.errors.push( - `"${field}" bindings should, optionally, have a boolean "experimental_remote" field but got ${JSON.stringify( + `"${field}" bindings should, optionally, have a boolean "remote" field but got ${JSON.stringify( value )}.` ); @@ -2069,7 +2069,7 @@ const validateWorkflowBinding: ValidatorFn = (diagnostics, field, value) => { "name", "class_name", "script_name", - "experimental_remote", + "remote", ]); return isValid; @@ -2258,7 +2258,7 @@ const validateNamedSimpleBinding = validateAdditionalProperties(diagnostics, field, Object.keys(value), [ "binding", - "experimental_remote", + "remote", ]); return isValid; @@ -2883,7 +2883,7 @@ const validateKVBinding: ValidatorFn = (diagnostics, field, value) => { "binding", "id", "preview_id", - "experimental_remote", + "remote", ]); return isValid; @@ -2943,7 +2943,7 @@ const validateSendEmailBinding: ValidatorFn = (diagnostics, field, value) => { "destination_address", "name", "binding", - "experimental_remote", + "remote", ]); return isValid; @@ -2962,7 +2962,7 @@ const validateQueueBinding: ValidatorFn = (diagnostics, field, value) => { "binding", "queue", "delivery_delay", - "experimental_remote", + "remote", ]) ) { return false; @@ -3094,7 +3094,7 @@ const validateR2Binding: ValidatorFn = (diagnostics, field, value) => { "bucket_name", "preview_bucket_name", "jurisdiction", - "experimental_remote", + "remote", ]); return isValid; @@ -3155,7 +3155,7 @@ const validateD1Binding: ValidatorFn = (diagnostics, field, value) => { "migrations_dir", "migrations_table", "preview_database_id", - "experimental_remote", + "remote", ]); return isValid; @@ -3194,7 +3194,7 @@ const validateVectorizeBinding: ValidatorFn = (diagnostics, field, value) => { validateAdditionalProperties(diagnostics, field, Object.keys(value), [ "binding", "index_name", - "experimental_remote", + "remote", ]); return isValid; @@ -3558,7 +3558,7 @@ const validateMTlsCertificateBinding: ValidatorFn = ( validateAdditionalProperties(diagnostics, field, Object.keys(value), [ "binding", "certificate_id", - "experimental_remote", + "remote", ]); if (!isRemoteValid(value, field, diagnostics)) { @@ -3739,7 +3739,7 @@ const validatePipelineBinding: ValidatorFn = (diagnostics, field, value) => { validateAdditionalProperties(diagnostics, field, Object.keys(value), [ "binding", "pipeline", - "experimental_remote", + "remote", ]); return isValid; @@ -4185,9 +4185,9 @@ function isRemoteValid( fieldPath: string, diagnostics: Diagnostics ) { - if (!isOptionalProperty(targetObject, "experimental_remote", "boolean")) { + if (!isOptionalProperty(targetObject, "remote", "boolean")) { diagnostics.errors.push( - `"${fieldPath}" should, optionally, have a boolean "experimental_remote" field but got ${JSON.stringify( + `"${fieldPath}" should, optionally, have a boolean "remote" field but got ${JSON.stringify( targetObject )}.` ); diff --git a/packages/wrangler/src/deploy/index.ts b/packages/wrangler/src/deploy/index.ts index a2bf3f67eb70..fb15ecbb35c6 100644 --- a/packages/wrangler/src/deploy/index.ts +++ b/packages/wrangler/src/deploy/index.ts @@ -243,7 +243,7 @@ export const deployCommand = createCommand({ overrideExperimentalFlags: (args) => ({ MULTIWORKER: false, RESOURCES_PROVISION: args.experimentalProvision ?? false, - REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false, + REMOTE_BINDINGS: args.experimentalRemoteBindings ?? true, DEPLOY_REMOTE_DIFF_CHECK: args.experimentalDeployRemoteDiffCheck ?? false, }), warnIfMultipleEnvsConfiguredButNoneSpecified: true, diff --git a/packages/wrangler/src/deployment-bundle/worker.ts b/packages/wrangler/src/deployment-bundle/worker.ts index b4005d4c0cb4..670934adb698 100644 --- a/packages/wrangler/src/deployment-bundle/worker.ts +++ b/packages/wrangler/src/deployment-bundle/worker.ts @@ -82,7 +82,7 @@ export interface CfVars { export interface CfKvNamespace { binding: string; id?: string | typeof INHERIT_SYMBOL; - experimental_remote?: boolean; + remote?: boolean; raw?: boolean; } @@ -91,7 +91,7 @@ export interface CfKvNamespace { */ export type CfSendEmailBindings = { name: string; - experimental_remote?: boolean; + remote?: boolean; } & ( | { destination_address?: string } | { allowed_destination_addresses?: string[] } @@ -125,7 +125,7 @@ export interface CfTextBlobBindings { export interface CfBrowserBinding { binding: string; raw?: boolean; - experimental_remote?: boolean; + remote?: boolean; } /** @@ -135,7 +135,7 @@ export interface CfBrowserBinding { export interface CfAIBinding { binding: string; staging?: boolean; - experimental_remote?: boolean; + remote?: boolean; raw?: boolean; } @@ -145,7 +145,7 @@ export interface CfAIBinding { export interface CfImagesBinding { binding: string; raw?: boolean; - experimental_remote?: boolean; + remote?: boolean; } /** @@ -179,7 +179,7 @@ export interface CfWorkflow { class_name: string; binding: string; script_name?: string; - experimental_remote?: boolean; + remote?: boolean; raw?: boolean; } @@ -187,7 +187,7 @@ export interface CfQueue { binding: string; queue_name: string; delivery_delay?: number; - experimental_remote?: boolean; + remote?: boolean; raw?: boolean; } @@ -195,7 +195,7 @@ export interface CfR2Bucket { binding: string; bucket_name?: string | typeof INHERIT_SYMBOL; jurisdiction?: string; - experimental_remote?: boolean; + remote?: boolean; raw?: boolean; } @@ -208,7 +208,7 @@ export interface CfD1Database { database_internal_env?: string; migrations_table?: string; migrations_dir?: string; - experimental_remote?: boolean; + remote?: boolean; raw?: boolean; } @@ -216,7 +216,7 @@ export interface CfVectorize { binding: string; index_name: string; raw?: boolean; - experimental_remote?: boolean; + remote?: boolean; } export interface CfSecretsStoreSecrets { @@ -242,7 +242,7 @@ export interface CfService { environment?: string; entrypoint?: string; props?: Record; - experimental_remote?: boolean; + remote?: boolean; } export interface CfAnalyticsEngineDataset { @@ -258,13 +258,13 @@ export interface CfDispatchNamespace { environment?: string; parameters?: string[]; }; - experimental_remote?: boolean; + remote?: boolean; } export interface CfMTlsCertificate { binding: string; certificate_id: string; - experimental_remote?: boolean; + remote?: boolean; } export interface CfLogfwdr { @@ -283,7 +283,7 @@ export interface CfAssetsBinding { export interface CfPipeline { binding: string; pipeline: string; - experimental_remote?: boolean; + remote?: boolean; } export interface CfUnsafeBinding { diff --git a/packages/wrangler/src/dev.ts b/packages/wrangler/src/dev.ts index d363aabe79b1..37a1250265f8 100644 --- a/packages/wrangler/src/dev.ts +++ b/packages/wrangler/src/dev.ts @@ -57,7 +57,7 @@ export const dev = createCommand({ overrideExperimentalFlags: (args) => ({ MULTIWORKER: Array.isArray(args.config), RESOURCES_PROVISION: args.experimentalProvision ?? false, - REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false, + REMOTE_BINDINGS: args.experimentalRemoteBindings ?? true, DEPLOY_REMOTE_DIFF_CHECK: false, }), }, @@ -281,12 +281,14 @@ export const dev = createCommand({ describe: "Bind to production Vectorize indexes in local development mode", default: false, + hidden: true, }, "experimental-images-local-mode": { type: "boolean", describe: "Use a local lower-fidelity implementation of the Images binding", default: false, + hidden: true, }, }, async validateArgs(args) { @@ -508,8 +510,6 @@ async function setupDevEnv( testScheduled: args.testScheduled, logLevel: args.logLevel, registry: args.disableDevRegistry ? undefined : getRegistryPath(), - bindVectorizeToProd: args.experimentalVectorizeBindToProd, - imagesLocalMode: args.experimentalImagesLocalMode, multiworkerPrimary: args.multiworkerPrimary, enableContainers: args.enableContainers, dockerPath: args.dockerPath, @@ -579,7 +579,7 @@ export async function startDev(args: StartDevOptions) { logger.log( bold( dedent` - Support for remote bindings in ${green("`wrangler dev`")} is now available in public beta as a replacement for ${green("`wrangler dev --remote`")}. Try it out now by running ${green("`wrangler dev --x-remote-bindings`")} with the ${green("`experimental_remote`")} option enabled on your resources and let us know how it goes! + Support for remote bindings in ${green("`wrangler dev`")} is now available as a replacement for ${green("`wrangler dev --remote`")}. Try it out now by running ${green("`wrangler dev`")} with the ${green("`remote`")} option enabled on your resources and let us know how it goes! This gives you access to remote resources in development while retaining all the usual benefits of local dev: fast iteration speed, breakpoint debugging, and more. Refer to https://developers.cloudflare.com/workers/development-testing/#remote-bindings for more information.` @@ -809,7 +809,7 @@ export function getBindings( */ // merge KV bindings const kvConfig = (configParam.kv_namespaces || []).map( - ({ binding, preview_id, id, experimental_remote }) => { + ({ binding, preview_id, id, remote }) => { // In remote `dev`, we make folks use a separate kv namespace called // `preview_id` instead of `id` so that they don't // break production data. So here we check that a `preview_id` @@ -830,7 +830,7 @@ export function getBindings( return { binding, id: preview_id ?? id, - experimental_remote: remoteBindingsEnabled && experimental_remote, + remote: remoteBindingsEnabled && remote, } satisfies CfKvNamespace; } ); @@ -851,7 +851,7 @@ export function getBindings( if (local) { return { ...d1Db, - experimental_remote: remoteBindingsEnabled && d1Db.experimental_remote, + remote: remoteBindingsEnabled && d1Db.remote, database_id, } satisfies CfD1Database; } @@ -869,13 +869,7 @@ export function getBindings( // merge R2 bindings const r2Config: EnvironmentNonInheritable["r2_buckets"] = configParam.r2_buckets?.map( - ({ - binding, - preview_bucket_name, - bucket_name, - jurisdiction, - experimental_remote, - }) => { + ({ binding, preview_bucket_name, bucket_name, jurisdiction, remote }) => { // same idea as kv namespace preview id, // same copy-on-write TODO if (!preview_bucket_name && !local) { @@ -890,7 +884,7 @@ export function getBindings( binding, bucket_name: preview_bucket_name ?? bucket_name, jurisdiction, - experimental_remote: remoteBindingsEnabled && experimental_remote, + remote: remoteBindingsEnabled && remote, } satisfies CfR2Bucket; } ) || []; @@ -908,10 +902,8 @@ export function getBindings( (service) => ({ ...service, - experimental_remote: - remoteBindingsEnabled && - "experimental_remote" in service && - !!service.experimental_remote, + remote: + remoteBindingsEnabled && "remote" in service && !!service.remote, }) satisfies CfService ); @@ -952,7 +944,7 @@ export function getBindings( binding: queue.binding, queue_name: queue.queue, delivery_delay: queue.delivery_delay, - experimental_remote: remoteBindingsEnabled && queue.experimental_remote, + remote: remoteBindingsEnabled && queue.remote, } satisfies CfQueue; }), ]; diff --git a/packages/wrangler/src/dev/miniflare/index.ts b/packages/wrangler/src/dev/miniflare/index.ts index 040834b23983..4bdc431b0ead 100644 --- a/packages/wrangler/src/dev/miniflare/index.ts +++ b/packages/wrangler/src/dev/miniflare/index.ts @@ -223,45 +223,40 @@ function getRemoteId(id: string | symbol | undefined): string | null { } function kvNamespaceEntry( - { binding, id: originalId, experimental_remote }: CfKvNamespace, + { binding, id: originalId, remote }: CfKvNamespace, remoteProxyConnectionString?: RemoteProxyConnectionString ): [ string, { id: string; remoteProxyConnectionString?: RemoteProxyConnectionString }, ] { const id = getRemoteId(originalId) ?? binding; - if (!remoteProxyConnectionString || !experimental_remote) { + if (!remoteProxyConnectionString || !remote) { return [binding, { id }]; } return [binding, { id, remoteProxyConnectionString }]; } function r2BucketEntry( - { binding, bucket_name, experimental_remote }: CfR2Bucket, + { binding, bucket_name, remote }: CfR2Bucket, remoteProxyConnectionString?: RemoteProxyConnectionString ): [ string, { id: string; remoteProxyConnectionString?: RemoteProxyConnectionString }, ] { const id = getRemoteId(bucket_name) ?? binding; - if (!remoteProxyConnectionString || !experimental_remote) { + if (!remoteProxyConnectionString || !remote) { return [binding, { id }]; } return [binding, { id, remoteProxyConnectionString }]; } function d1DatabaseEntry( - { - binding, - database_id, - preview_database_id, - experimental_remote, - }: CfD1Database, + { binding, database_id, preview_database_id, remote }: CfD1Database, remoteProxyConnectionString?: RemoteProxyConnectionString ): [ string, { id: string; remoteProxyConnectionString?: RemoteProxyConnectionString }, ] { const id = getRemoteId(preview_database_id ?? database_id) ?? binding; - if (!remoteProxyConnectionString || !experimental_remote) { + if (!remoteProxyConnectionString || !remote) { return [binding, { id }]; } return [binding, { id, remoteProxyConnectionString }]; @@ -271,7 +266,7 @@ function queueProducerEntry( binding, queue_name: queueName, delivery_delay: deliveryDelay, - experimental_remote, + remote, }: CfQueue, remoteProxyConnectionString?: RemoteProxyConnectionString ): [ @@ -282,7 +277,7 @@ function queueProducerEntry( remoteProxyConnectionString?: RemoteProxyConnectionString; }, ] { - if (!remoteProxyConnectionString || !experimental_remote) { + if (!remoteProxyConnectionString || !remote) { return [binding, { queueName, deliveryDelay }]; } @@ -298,7 +293,7 @@ function pipelineEntry( remoteProxyConnectionString?: RemoteProxyConnectionString; }, ] { - if (!remoteProxyConnectionString || !pipeline.experimental_remote) { + if (!remoteProxyConnectionString || !pipeline.remote) { return [pipeline.binding, { pipeline: pipeline.pipeline }]; } return [ @@ -315,7 +310,7 @@ function workflowEntry( name, class_name: className, script_name: scriptName, - experimental_remote, + remote, }: CfWorkflow, remoteProxyConnectionString?: RemoteProxyConnectionString ): [ @@ -327,7 +322,7 @@ function workflowEntry( remoteProxyConnectionString?: RemoteProxyConnectionString; }, ] { - if (!remoteProxyConnectionString || !experimental_remote) { + if (!remoteProxyConnectionString || !remote) { return [ binding, { @@ -351,10 +346,10 @@ function workflowEntry( function dispatchNamespaceEntry({ binding, namespace, - experimental_remote, + remote, }: CfDispatchNamespace): [string, { namespace: string }]; function dispatchNamespaceEntry( - { binding, namespace, experimental_remote }: CfDispatchNamespace, + { binding, namespace, remote }: CfDispatchNamespace, remoteProxyConnectionString: RemoteProxyConnectionString ): [ string, @@ -364,7 +359,7 @@ function dispatchNamespaceEntry( }, ]; function dispatchNamespaceEntry( - { binding, namespace, experimental_remote }: CfDispatchNamespace, + { binding, namespace, remote }: CfDispatchNamespace, remoteProxyConnectionString?: RemoteProxyConnectionString ): [ string, @@ -373,7 +368,7 @@ function dispatchNamespaceEntry( remoteProxyConnectionString?: RemoteProxyConnectionString; }, ] { - if (!remoteProxyConnectionString || !experimental_remote) { + if (!remoteProxyConnectionString || !remote) { return [binding, { namespace }]; } return [binding, { namespace, remoteProxyConnectionString }]; @@ -482,7 +477,7 @@ export function buildMiniflareBindingOptions( }; for (const service of config.services ?? []) { - if (remoteProxyConnectionString && service.experimental_remote) { + if (remoteProxyConnectionString && service.remote) { serviceBindings[service.binding] = { name: service.service, props: service.props, @@ -534,20 +529,16 @@ export function buildMiniflareBindingOptions( } if (bindings.ai && remoteBindingsEnabled) { - warnOrError("ai", bindings.ai.experimental_remote, "always-remote"); + warnOrError("ai", bindings.ai.remote, "always-remote"); } if (bindings.browser && remoteBindingsEnabled) { - warnOrError("browser", bindings.browser.experimental_remote, "remote"); + warnOrError("browser", bindings.browser.remote, "remote"); } if (bindings.mtls_certificates && remoteBindingsEnabled) { for (const mtls of bindings.mtls_certificates) { - warnOrError( - "mtls_certificates", - mtls.experimental_remote, - "always-remote" - ); + warnOrError("mtls_certificates", mtls.remote, "always-remote"); } } @@ -732,7 +723,7 @@ export function buildMiniflareBindingOptions( send_email: bindings.send_email?.map((b) => ({ ...b, remoteProxyConnectionString: - b.experimental_remote && remoteProxyConnectionString + b.remote && remoteProxyConnectionString ? remoteProxyConnectionString : undefined, })), @@ -742,7 +733,7 @@ export function buildMiniflareBindingOptions( ? { binding: bindings.images.binding, remoteProxyConnectionString: - bindings.images.experimental_remote && remoteProxyConnectionString + bindings.images.remote && remoteProxyConnectionString ? remoteProxyConnectionString : undefined, } @@ -753,7 +744,7 @@ export function buildMiniflareBindingOptions( remoteProxyConnectionString: remoteBindingsEnabled && remoteProxyConnectionString && - bindings.browser?.experimental_remote + bindings.browser?.remote ? remoteProxyConnectionString : undefined, } @@ -764,8 +755,8 @@ export function buildMiniflareBindingOptions( ? Object.fromEntries( bindings.vectorize ?.filter((v) => { - warnOrError("vectorize", v.experimental_remote, "remote"); - return v.experimental_remote; + warnOrError("vectorize", v.remote, "remote"); + return v.remote; }) .map((vectorize) => { return [ @@ -784,12 +775,8 @@ export function buildMiniflareBindingOptions( ? Object.fromEntries( bindings.dispatch_namespaces ?.filter((d) => { - warnOrError( - "dispatch_namespaces", - d.experimental_remote, - "remote" - ); - return d.experimental_remote; + warnOrError("dispatch_namespaces", d.remote, "remote"); + return d.remote; }) .map((dispatchNamespace) => dispatchNamespaceEntry( @@ -834,12 +821,8 @@ export function buildMiniflareBindingOptions( ? Object.fromEntries( bindings.mtls_certificates ?.filter((d) => { - warnOrError( - "mtls_certificates", - d.experimental_remote, - "remote" - ); - return d.experimental_remote; + warnOrError("mtls_certificates", d.remote, "remote"); + return d.remote; }) .map((mtlsCertificate) => [ mtlsCertificate.binding, diff --git a/packages/wrangler/src/index.ts b/packages/wrangler/src/index.ts index b9b5d87421eb..a006a7cb4fda 100644 --- a/packages/wrangler/src/index.ts +++ b/packages/wrangler/src/index.ts @@ -376,6 +376,7 @@ export function createCLIParser(argv: string[]) { describe: `Experimental: Enable Remote Bindings`, type: "boolean", hidden: true, + default: true, alias: ["x-remote-bindings"], }, "experimental-provision": { diff --git a/packages/wrangler/src/pages/dev.ts b/packages/wrangler/src/pages/dev.ts index 7889e559cae8..64381df9c978 100644 --- a/packages/wrangler/src/pages/dev.ts +++ b/packages/wrangler/src/pages/dev.ts @@ -952,7 +952,7 @@ export const pagesDevCommand = createCommand({ persistTo: args.persistTo, logLevel: args.logLevel ?? "log", experimentalProvision: undefined, - experimentalRemoteBindings: false, + experimentalRemoteBindings: true, experimentalVectorizeBindToProd: false, experimentalImagesLocalMode: false, enableIpc: true, diff --git a/packages/wrangler/src/utils/print-bindings.ts b/packages/wrangler/src/utils/print-bindings.ts index 670ac61b228c..45c5730a1383 100644 --- a/packages/wrangler/src/utils/print-bindings.ts +++ b/packages/wrangler/src/utils/print-bindings.ts @@ -160,35 +160,33 @@ export function printBindings( if (workflows !== undefined && workflows.length > 0) { output.push( - ...workflows.map( - ({ class_name, script_name, binding, experimental_remote }) => { - let value = class_name; - if (script_name) { - value += ` (defined in ${script_name})`; - } - - return { - name: binding, - type: friendlyBindingNames.workflows, - value: value, - mode: getMode({ - isSimulatedLocally: script_name ? !experimental_remote : true, - }), - }; + ...workflows.map(({ class_name, script_name, binding, remote }) => { + let value = class_name; + if (script_name) { + value += ` (defined in ${script_name})`; } - ) + + return { + name: binding, + type: friendlyBindingNames.workflows, + value: value, + mode: getMode({ + isSimulatedLocally: script_name ? !remote : true, + }), + }; + }) ); } if (kv_namespaces !== undefined && kv_namespaces.length > 0) { output.push( - ...kv_namespaces.map(({ binding, id, experimental_remote }) => { + ...kv_namespaces.map(({ binding, id, remote }) => { return { name: binding, type: friendlyBindingNames.kv_namespaces, value: id, mode: getMode({ - isSimulatedLocally: !experimental_remote, + isSimulatedLocally: !remote, }), }; }) @@ -215,7 +213,7 @@ export function printBindings( "unrestricted", mode: getMode({ isSimulatedLocally: getFlag("REMOTE_BINDINGS") - ? !emailBinding.experimental_remote + ? !emailBinding.remote : true, }), }; @@ -225,13 +223,13 @@ export function printBindings( if (queues !== undefined && queues.length > 0) { output.push( - ...queues.map(({ binding, queue_name, experimental_remote }) => { + ...queues.map(({ binding, queue_name, remote }) => { return { name: binding, type: friendlyBindingNames.queues, value: queue_name, mode: getMode({ - isSimulatedLocally: !experimental_remote, + isSimulatedLocally: !remote, }), }; }) @@ -246,7 +244,7 @@ export function printBindings( database_name, database_id, preview_database_id, - experimental_remote, + remote, }) => { const value = typeof database_id == "symbol" @@ -257,7 +255,7 @@ export function printBindings( name: binding, type: friendlyBindingNames.d1_databases, mode: getMode({ - isSimulatedLocally: !experimental_remote, + isSimulatedLocally: !remote, }), value, }; @@ -268,14 +266,14 @@ export function printBindings( if (vectorize !== undefined && vectorize.length > 0) { output.push( - ...vectorize.map(({ binding, index_name, experimental_remote }) => { + ...vectorize.map(({ binding, index_name, remote }) => { return { name: binding, type: friendlyBindingNames.vectorize, value: index_name, mode: getMode({ isSimulatedLocally: getFlag("REMOTE_BINDINGS") - ? experimental_remote + ? remote ? false : undefined : context.vectorizeBindToProd @@ -302,25 +300,23 @@ export function printBindings( if (r2_buckets !== undefined && r2_buckets.length > 0) { output.push( - ...r2_buckets.map( - ({ binding, bucket_name, jurisdiction, experimental_remote }) => { - const value = - typeof bucket_name === "symbol" - ? bucket_name - : bucket_name - ? `${bucket_name}${jurisdiction ? ` (${jurisdiction})` : ""}` - : undefined; + ...r2_buckets.map(({ binding, bucket_name, jurisdiction, remote }) => { + const value = + typeof bucket_name === "symbol" + ? bucket_name + : bucket_name + ? `${bucket_name}${jurisdiction ? ` (${jurisdiction})` : ""}` + : undefined; - return { - name: binding, - type: friendlyBindingNames.r2_buckets, - value: value, - mode: getMode({ - isSimulatedLocally: !experimental_remote, - }), - }; - } - ) + return { + name: binding, + type: friendlyBindingNames.r2_buckets, + value: value, + mode: getMode({ + isSimulatedLocally: !remote, + }), + }; + }) ); } @@ -365,40 +361,38 @@ export function printBindings( if (services !== undefined && services.length > 0) { output.push( - ...services.map( - ({ binding, service, entrypoint, experimental_remote }) => { - let value = service; - let mode = undefined; - - if (entrypoint) { - value += `#${entrypoint}`; - } + ...services.map(({ binding, service, entrypoint, remote }) => { + let value = service; + let mode = undefined; - if (experimental_remote) { - mode = getMode({ isSimulatedLocally: false }); - } else if (context.local && context.registry !== null) { - const registryDefinition = context.registry?.[service]; - hasConnectionStatus = true; + if (entrypoint) { + value += `#${entrypoint}`; + } - if ( - registryDefinition && - (!entrypoint || - registryDefinition.entrypointAddresses?.[entrypoint]) - ) { - mode = getMode({ isSimulatedLocally: true, connected: true }); - } else { - mode = getMode({ isSimulatedLocally: true, connected: false }); - } + if (remote) { + mode = getMode({ isSimulatedLocally: false }); + } else if (context.local && context.registry !== null) { + const registryDefinition = context.registry?.[service]; + hasConnectionStatus = true; + + if ( + registryDefinition && + (!entrypoint || + registryDefinition.entrypointAddresses?.[entrypoint]) + ) { + mode = getMode({ isSimulatedLocally: true, connected: true }); + } else { + mode = getMode({ isSimulatedLocally: true, connected: false }); } - - return { - name: binding, - type: friendlyBindingNames.services, - value, - mode, - }; } - ) + + return { + name: binding, + type: friendlyBindingNames.services, + value, + mode, + }; + }) ); } @@ -435,9 +429,7 @@ export function printBindings( type: friendlyBindingNames.browser, value: undefined, mode: getMode({ - isSimulatedLocally: !( - getFlag("REMOTE_BINDINGS") && browser.experimental_remote - ), + isSimulatedLocally: !(getFlag("REMOTE_BINDINGS") && browser.remote), }), }); } @@ -449,8 +441,7 @@ export function printBindings( value: undefined, mode: getMode({ isSimulatedLocally: getFlag("REMOTE_BINDINGS") - ? images.experimental_remote === true || - images.experimental_remote === undefined + ? images.remote === true || images.remote === undefined ? false : undefined : !!context.imagesLocalMode, @@ -465,8 +456,7 @@ export function printBindings( value: ai.staging ? `staging` : undefined, mode: getMode({ isSimulatedLocally: getFlag("REMOTE_BINDINGS") - ? ai.experimental_remote === true || - ai.experimental_remote === undefined + ? ai.remote === true || ai.remote === undefined ? false : undefined : false, @@ -476,14 +466,12 @@ export function printBindings( if (pipelines?.length) { output.push( - ...pipelines.map(({ binding, pipeline, experimental_remote }) => ({ + ...pipelines.map(({ binding, pipeline, remote }) => ({ name: binding, type: friendlyBindingNames.pipelines, value: pipeline, mode: getMode({ - isSimulatedLocally: getFlag("REMOTE_BINDINGS") - ? !experimental_remote - : true, + isSimulatedLocally: getFlag("REMOTE_BINDINGS") ? !remote : true, }), })) ); @@ -557,46 +545,41 @@ export function printBindings( if (dispatch_namespaces !== undefined && dispatch_namespaces.length > 0) { output.push( - ...dispatch_namespaces.map( - ({ binding, namespace, outbound, experimental_remote }) => { - return { - name: binding, - type: friendlyBindingNames.dispatch_namespaces, - value: outbound - ? `${namespace} (outbound -> ${outbound.service})` - : namespace, - mode: getMode({ - isSimulatedLocally: getFlag("REMOTE_BINDINGS") - ? experimental_remote - ? false - : undefined - : undefined, - }), - }; - } - ) + ...dispatch_namespaces.map(({ binding, namespace, outbound, remote }) => { + return { + name: binding, + type: friendlyBindingNames.dispatch_namespaces, + value: outbound + ? `${namespace} (outbound -> ${outbound.service})` + : namespace, + mode: getMode({ + isSimulatedLocally: getFlag("REMOTE_BINDINGS") + ? remote + ? false + : undefined + : undefined, + }), + }; + }) ); } if (mtls_certificates !== undefined && mtls_certificates.length > 0) { output.push( - ...mtls_certificates.map( - ({ binding, certificate_id, experimental_remote }) => { - return { - name: binding, - type: friendlyBindingNames.mtls_certificates, - value: certificate_id, - mode: getMode({ - isSimulatedLocally: getFlag("REMOTE_BINDINGS") - ? experimental_remote === true || - experimental_remote === undefined - ? false - : undefined - : false, - }), - }; - } - ) + ...mtls_certificates.map(({ binding, certificate_id, remote }) => { + return { + name: binding, + type: friendlyBindingNames.mtls_certificates, + value: certificate_id, + mode: getMode({ + isSimulatedLocally: getFlag("REMOTE_BINDINGS") + ? remote === true || remote === undefined + ? false + : undefined + : false, + }), + }; + }) ); } @@ -795,7 +778,7 @@ export function warnOrError( } if (remote === false && supports === "remote") { throw new UserError( - `${friendlyBindingNames[type]} bindings do not support local development. You may be able to set \`experimental_remote: true\` for the binding definition in your configuration file to access a remote version of the resource.`, + `${friendlyBindingNames[type]} bindings do not support local development. You may be able to set \`remote: true\` for the binding definition in your configuration file to access a remote version of the resource.`, { telemetryMessage: true, } @@ -803,12 +786,12 @@ export function warnOrError( } if (remote === undefined && supports === "remote") { logger.warn( - `${friendlyBindingNames[type]} bindings do not support local development, and so parts of your Worker may not work correctly. You may be able to set \`experimental_remote: true\` for the binding definition in your configuration file to access a remote version of the resource.` + `${friendlyBindingNames[type]} bindings do not support local development, and so parts of your Worker may not work correctly. You may be able to set \`remote: true\` for the binding definition in your configuration file to access a remote version of the resource.` ); } if (remote === undefined && supports === "always-remote") { logger.warn( - `${friendlyBindingNames[type]} bindings always access remote resources, and so may incur usage charges even in local dev. To suppress this warning, set \`experimental_remote: true\` for the binding definition in your configuration file.` + `${friendlyBindingNames[type]} bindings always access remote resources, and so may incur usage charges even in local dev. To suppress this warning, set \`remote: true\` for the binding definition in your configuration file.` ); } } diff --git a/packages/wrangler/src/versions/upload.ts b/packages/wrangler/src/versions/upload.ts index 3fa5203be858..eec4e74a7616 100644 --- a/packages/wrangler/src/versions/upload.ts +++ b/packages/wrangler/src/versions/upload.ts @@ -264,7 +264,7 @@ export const versionsUploadCommand = createCommand({ overrideExperimentalFlags: (args) => ({ MULTIWORKER: false, RESOURCES_PROVISION: args.experimentalProvision ?? false, - REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false, + REMOTE_BINDINGS: args.experimentalRemoteBindings ?? true, DEPLOY_REMOTE_DIFF_CHECK: false, }), warnIfMultipleEnvsConfiguredButNoneSpecified: true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d5658c5bdd45..3ce9437a4700 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -174,24 +174,6 @@ importers: specifier: workspace:* version: link:../../packages/wrangler - fixtures/ai-app: - devDependencies: - '@cloudflare/workers-tsconfig': - specifier: workspace:^ - version: link:../../packages/workers-tsconfig - typescript: - specifier: catalog:default - version: 5.8.3 - undici: - specifier: catalog:default - version: 7.14.0 - vitest: - specifier: catalog:default - version: 3.2.3(@types/debug@4.1.12)(@types/node@20.19.9)(@vitest/ui@3.2.3)(jiti@2.4.2)(lightningcss@1.29.2)(msw@2.4.3(typescript@5.8.3))(supports-color@9.2.2) - wrangler: - specifier: workspace:* - version: link:../../packages/wrangler - fixtures/browser-rendering: devDependencies: '@cloudflare/playwright':