diff --git a/.changeset/nice-falcons-yell.md b/.changeset/nice-falcons-yell.md new file mode 100644 index 000000000000..61aff70e3917 --- /dev/null +++ b/.changeset/nice-falcons-yell.md @@ -0,0 +1,8 @@ +--- +"@cloudflare/vite-plugin": patch +"@cloudflare/vitest-pool-workers": patch +"miniflare": patch +"wrangler": patch +--- + +Remove the Mixed Mode naming in favour of "remote bindings"/"remote proxy" diff --git a/fixtures/vitest-pool-workers-mixed-mode/remote-worker.js b/fixtures/vitest-pool-workers-mixed-mode/remote-worker.js deleted file mode 100644 index 0dfea1737c33..000000000000 --- a/fixtures/vitest-pool-workers-mixed-mode/remote-worker.js +++ /dev/null @@ -1,7 +0,0 @@ -export default { - fetch() { - return new Response( - "Hello from a remote worker part of the vitest-pool-workers mixed mode fixture!" - ); - }, -}; diff --git a/fixtures/vitest-pool-workers-mixed-mode/wrangler.json b/fixtures/vitest-pool-workers-mixed-mode/wrangler.json deleted file mode 100644 index c7841cc14a7e..000000000000 --- a/fixtures/vitest-pool-workers-mixed-mode/wrangler.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "vitest-mixed-mode-fixture-test", - "main": "src/index.js", - "compatibility_date": "2025-06-01", - "services": [ - { "binding": "MY_WORKER", "service": "my-worker-test", "remote": true } - ] -} diff --git a/fixtures/vitest-pool-workers-mixed-mode/package.json b/fixtures/vitest-pool-workers-remote-bindings/package.json similarity index 84% rename from fixtures/vitest-pool-workers-mixed-mode/package.json rename to fixtures/vitest-pool-workers-remote-bindings/package.json index 149ad7995251..1d7a5d62629a 100644 --- a/fixtures/vitest-pool-workers-mixed-mode/package.json +++ b/fixtures/vitest-pool-workers-remote-bindings/package.json @@ -1,5 +1,5 @@ { - "name": "@fixture/vitest-pool-workers-mixed-mode", + "name": "@fixture/vitest-pool-workers-remote-bindings", "private": true, "scripts": { "test": "vitest run --config vitest.workers.config.ts", diff --git a/fixtures/vitest-pool-workers-remote-bindings/remote-worker.js b/fixtures/vitest-pool-workers-remote-bindings/remote-worker.js new file mode 100644 index 000000000000..3e6f023a8dfc --- /dev/null +++ b/fixtures/vitest-pool-workers-remote-bindings/remote-worker.js @@ -0,0 +1,7 @@ +export default { + fetch() { + return new Response( + "Hello from a remote Worker part of the vitest-pool-workers remote bindings fixture!" + ); + }, +}; diff --git a/fixtures/vitest-pool-workers-mixed-mode/run-tests.mjs b/fixtures/vitest-pool-workers-remote-bindings/run-tests.mjs similarity index 100% rename from fixtures/vitest-pool-workers-mixed-mode/run-tests.mjs rename to fixtures/vitest-pool-workers-remote-bindings/run-tests.mjs diff --git a/fixtures/vitest-pool-workers-mixed-mode/src/index.js b/fixtures/vitest-pool-workers-remote-bindings/src/index.js similarity index 100% rename from fixtures/vitest-pool-workers-mixed-mode/src/index.js rename to fixtures/vitest-pool-workers-remote-bindings/src/index.js diff --git a/fixtures/vitest-pool-workers-mixed-mode/test/index.spec.ts b/fixtures/vitest-pool-workers-remote-bindings/test/index.spec.ts similarity index 78% rename from fixtures/vitest-pool-workers-mixed-mode/test/index.spec.ts rename to fixtures/vitest-pool-workers-remote-bindings/test/index.spec.ts index d805c49fceaa..384df4de30cd 100644 --- a/fixtures/vitest-pool-workers-mixed-mode/test/index.spec.ts +++ b/fixtures/vitest-pool-workers-remote-bindings/test/index.spec.ts @@ -18,7 +18,7 @@ describe("Hello World worker", () => { const response = await env.MY_WORKER.fetch(request, env, ctx); await waitOnExecutionContext(ctx); expect(await response.text()).toMatchInlineSnapshot( - `"Hello from a remote worker part of the vitest-pool-workers mixed mode fixture!"` + `"Hello from a remote Worker part of the vitest-pool-workers remote bindings fixture!"` ); } ); @@ -26,7 +26,7 @@ describe("Hello World worker", () => { it("responds with Hello World! (integration style)", async () => { const response = await SELF.fetch("https://example.com"); expect(await response.text()).toMatchInlineSnapshot( - `"Response from remote worker: Hello from a remote worker part of the vitest-pool-workers mixed mode fixture!"` + `"Response from remote worker: Hello from a remote Worker part of the vitest-pool-workers remote bindings fixture!"` ); }); }); diff --git a/fixtures/vitest-pool-workers-mixed-mode/vitest.workers.config.ts b/fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.ts similarity index 97% rename from fixtures/vitest-pool-workers-mixed-mode/vitest.workers.config.ts rename to fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.ts index 86995f36670d..6a476d79b5e1 100644 --- a/fixtures/vitest-pool-workers-mixed-mode/vitest.workers.config.ts +++ b/fixtures/vitest-pool-workers-remote-bindings/vitest.workers.config.ts @@ -15,7 +15,7 @@ export default defineWorkersConfig({ test: { poolOptions: { workers: { - experimental_mixedMode: true, + 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 new file mode 100644 index 000000000000..75d57aee81ab --- /dev/null +++ b/fixtures/vitest-pool-workers-remote-bindings/wrangler.json @@ -0,0 +1,12 @@ +{ + "name": "vitest-remote-bindings-fixture-test", + "main": "src/index.js", + "compatibility_date": "2025-06-01", + "services": [ + { + "binding": "MY_WORKER", + "service": "my-worker-test", + "experimental_remote": true + } + ] +} diff --git a/packages/miniflare/src/index.ts b/packages/miniflare/src/index.ts index fb20dafbf487..f487f4d86968 100644 --- a/packages/miniflare/src/index.ts +++ b/packages/miniflare/src/index.ts @@ -432,12 +432,12 @@ function getExternalServiceEntrypoints( for (const [name, service] of Object.entries( workerOpts.core.serviceBindings )) { - const { serviceName, entrypoint, mixedModeConnectionString } = + const { serviceName, entrypoint, remoteProxyConnectionString } = normaliseServiceDesignator(service); if ( // Skip if it is a remote service - mixedModeConnectionString === undefined && + remoteProxyConnectionString === undefined && // Skip if the service is bound to another Worker defined in the Miniflare config serviceName && !allWorkerNames.includes(serviceName) @@ -466,12 +466,12 @@ function getExternalServiceEntrypoints( scriptName, unsafePreventEviction, enableSql: useSQLite, - mixedModeConnectionString, + remoteProxyConnectionString, } = normaliseDurableObject(designator); if ( // Skip if it is a remote durable object - mixedModeConnectionString === undefined && + remoteProxyConnectionString === undefined && // Skip if the durable object is bound to a Worker that exists in the current Miniflare config scriptName && !allWorkerNames.includes(scriptName) @@ -501,12 +501,12 @@ function getExternalServiceEntrypoints( const { serviceName = workerOpts.core.name, entrypoint, - mixedModeConnectionString, + remoteProxyConnectionString, } = normaliseServiceDesignator(workerOpts.core.tails[i]); if ( // Skip if it is a remote service - mixedModeConnectionString === undefined && + remoteProxyConnectionString === undefined && // Skip if the service is bound to the existing workers serviceName && !allWorkerNames.includes(serviceName) @@ -2196,7 +2196,7 @@ export class Miniflare { workerOpts.do.durableObjects ?? {} ).reduce( (internalObjects, [bindingName, designator]) => { - const { className, scriptName, mixedModeConnectionString } = + const { className, scriptName, remoteProxyConnectionString } = normaliseDurableObject(designator); if ( @@ -2205,7 +2205,7 @@ export class Miniflare { // If the scriptName matches one of the workers defined, it is internal as well allWorkerNames.includes(scriptName) || // If it is not a remote durable object - mixedModeConnectionString === undefined + remoteProxyConnectionString === undefined ) { internalObjects.push({ name: bindingName, diff --git a/packages/miniflare/src/plugins/ai/index.ts b/packages/miniflare/src/plugins/ai/index.ts index 78c048ff2121..5eb7e530fba3 100644 --- a/packages/miniflare/src/plugins/ai/index.ts +++ b/packages/miniflare/src/plugins/ai/index.ts @@ -1,15 +1,15 @@ import assert from "node:assert"; import { z } from "zod"; import { - mixedModeClientWorker, - MixedModeConnectionString, Plugin, ProxyNodeBinding, + remoteProxyClientWorker, + RemoteProxyConnectionString, } from "../shared"; const AISchema = z.object({ binding: z.string(), - mixedModeConnectionString: z.custom(), + remoteProxyConnectionString: z.custom(), }); export const AIOptionsSchema = z.object({ @@ -26,8 +26,8 @@ export const AI_PLUGIN: Plugin = { } assert( - options.ai.mixedModeConnectionString, - "Workers AI only supports Mixed Mode" + options.ai.remoteProxyConnectionString, + "Workers AI only supports running remotely" ); return [ @@ -61,8 +61,8 @@ export const AI_PLUGIN: Plugin = { return [ { name: `${AI_PLUGIN_NAME}:${options.ai.binding}`, - worker: mixedModeClientWorker( - options.ai.mixedModeConnectionString, + worker: remoteProxyClientWorker( + options.ai.remoteProxyConnectionString, options.ai.binding ), }, diff --git a/packages/miniflare/src/plugins/browser-rendering/index.ts b/packages/miniflare/src/plugins/browser-rendering/index.ts index 8dbb15b73100..af739eb700e2 100644 --- a/packages/miniflare/src/plugins/browser-rendering/index.ts +++ b/packages/miniflare/src/plugins/browser-rendering/index.ts @@ -1,15 +1,15 @@ import assert from "node:assert"; import { z } from "zod"; import { - mixedModeClientWorker, - MixedModeConnectionString, Plugin, ProxyNodeBinding, + remoteProxyClientWorker, + RemoteProxyConnectionString, } from "../shared"; const BrowserRenderingSchema = z.object({ binding: z.string(), - mixedModeConnectionString: z.custom(), + remoteProxyConnectionString: z.custom(), }); export const BrowserRenderingOptionsSchema = z.object({ @@ -28,8 +28,8 @@ export const BROWSER_RENDERING_PLUGIN: Plugin< } assert( - options.browserRendering.mixedModeConnectionString, - "Workers Browser Rendering only supports Mixed Mode" + options.browserRendering.remoteProxyConnectionString, + "Workers Browser Rendering only supports running remotely" ); return [ @@ -55,15 +55,15 @@ export const BROWSER_RENDERING_PLUGIN: Plugin< } assert( - options.browserRendering.mixedModeConnectionString, - "Workers Browser Rendering only supports Mixed Mode" + options.browserRendering.remoteProxyConnectionString, + "Workers Browser Rendering only supports running remotely" ); return [ { name: `${BROWSER_RENDERING_PLUGIN_NAME}:${options.browserRendering.binding}`, - worker: mixedModeClientWorker( - options.browserRendering.mixedModeConnectionString, + worker: remoteProxyClientWorker( + options.browserRendering.remoteProxyConnectionString, options.browserRendering.binding ), }, diff --git a/packages/miniflare/src/plugins/core/index.ts b/packages/miniflare/src/plugins/core/index.ts index 4871fd9cf60c..2873cea317c7 100644 --- a/packages/miniflare/src/plugins/core/index.ts +++ b/packages/miniflare/src/plugins/core/index.ts @@ -41,10 +41,10 @@ import { getCacheServiceName } from "../cache"; import { DURABLE_OBJECTS_STORAGE_SERVICE_NAME } from "../do"; import { kUnsafeEphemeralUniqueKey, - mixedModeClientWorker, parseRoutes, Plugin, ProxyNodeBinding, + remoteProxyClientWorker, SERVICE_LOOPBACK, WORKER_BINDING_SERVICE_LOOPBACK, } from "../shared"; @@ -299,9 +299,9 @@ function getCustomServiceDesignator( } else if (typeof service === "object") { if ("node" in service) { serviceName = getCustomNodeServiceName(workerIndex, kind, name); - } else if ("mixedModeConnectionString" in service) { + } else if ("remoteProxyConnectionString" in service) { assert("name" in service && typeof service.name === "string"); - serviceName = `${CORE_PLUGIN_NAME}:mixed-mode-service:${workerIndex}:${name}`; + serviceName = `${CORE_PLUGIN_NAME}:remote-proxy-service:${workerIndex}:${name}`; } // Worker with entrypoint else if ("name" in service) { @@ -378,17 +378,20 @@ function maybeGetCustomServiceService( }; } else if ( typeof service === "object" && - service.mixedModeConnectionString !== undefined + service.remoteProxyConnectionString !== undefined ) { assert( - service.mixedModeConnectionString && + service.remoteProxyConnectionString && service.name && typeof service.name === "string" ); return { - name: `${CORE_PLUGIN_NAME}:mixed-mode-service:${workerIndex}:${name}`, - worker: mixedModeClientWorker(service.mixedModeConnectionString, name), + name: `${CORE_PLUGIN_NAME}:remote-proxy-service:${workerIndex}:${name}`, + worker: remoteProxyClientWorker( + service.remoteProxyConnectionString, + name + ), }; } } diff --git a/packages/miniflare/src/plugins/core/services.ts b/packages/miniflare/src/plugins/core/services.ts index 6aef394fd793..9ae47d667cec 100644 --- a/packages/miniflare/src/plugins/core/services.ts +++ b/packages/miniflare/src/plugins/core/services.ts @@ -3,7 +3,7 @@ import { Request, Response } from "../../http"; import { HOST_CAPNP_CONNECT, Miniflare, - MixedModeConnectionString, + RemoteProxyConnectionString, } from "../../index"; import { ExternalServer, @@ -104,7 +104,9 @@ export const ServiceDesignatorSchema = z.union([ name: z.union([z.string(), z.literal(kCurrentWorker)]), entrypoint: z.ostring(), props: z.record(z.unknown()).optional(), - mixedModeConnectionString: z.custom().optional(), + remoteProxyConnectionString: z + .custom() + .optional(), }), z.object({ network: NetworkSchema }), z.object({ external: ExternalServerSchema }), diff --git a/packages/miniflare/src/plugins/d1/index.ts b/packages/miniflare/src/plugins/d1/index.ts index 912d03d00368..abfdecc103de 100644 --- a/packages/miniflare/src/plugins/d1/index.ts +++ b/packages/miniflare/src/plugins/d1/index.ts @@ -12,14 +12,14 @@ import { getMiniflareObjectBindings, getPersistPath, migrateDatabase, - mixedModeClientWorker, - MixedModeConnectionString, namespaceEntries, namespaceKeys, objectEntryWorker, PersistenceSchema, Plugin, ProxyNodeBinding, + remoteProxyClientWorker, + RemoteProxyConnectionString, SERVICE_LOOPBACK, } from "../shared"; @@ -30,8 +30,8 @@ export const D1OptionsSchema = z.object({ z.record( z.object({ id: z.string(), - mixedModeConnectionString: z - .custom() + remoteProxyConnectionString: z + .custom() .optional(), }) ), @@ -61,10 +61,10 @@ export const D1_PLUGIN: Plugin< getBindings(options) { const databases = namespaceEntries(options.d1Databases); return databases.map( - ([name, { id, mixedModeConnectionString }]) => { + ([name, { id, remoteProxyConnectionString }]) => { assert( - !(name.startsWith("__D1_BETA__") && mixedModeConnectionString), - "Mixed Mode cannot be used with Alpha D1 Databases" + !(name.startsWith("__D1_BETA__") && remoteProxyConnectionString), + "Alpha D1 Databases cannot run remotely" ); const binding = name.startsWith("__D1_BETA__") @@ -106,10 +106,10 @@ export const D1_PLUGIN: Plugin< const persist = sharedOptions.d1Persist; const databases = namespaceEntries(options.d1Databases); const services = databases.map( - ([name, { id, mixedModeConnectionString }]) => ({ + ([name, { id, remoteProxyConnectionString }]) => ({ name: `${D1_DATABASE_SERVICE_PREFIX}:${id}`, - worker: mixedModeConnectionString - ? mixedModeClientWorker(mixedModeConnectionString, name) + worker: remoteProxyConnectionString + ? remoteProxyClientWorker(remoteProxyConnectionString, name) : objectEntryWorker(D1_DATABASE_OBJECT, id), }) ); diff --git a/packages/miniflare/src/plugins/dispatch-namespace/index.ts b/packages/miniflare/src/plugins/dispatch-namespace/index.ts index 5ea2e3411133..28b817a32de7 100644 --- a/packages/miniflare/src/plugins/dispatch-namespace/index.ts +++ b/packages/miniflare/src/plugins/dispatch-namespace/index.ts @@ -3,10 +3,10 @@ import LOCAL_DISPATCH_NAMESPACE from "worker:dispatch-namespace/dispatch-namespa import { z } from "zod"; import { Worker_Binding } from "../../runtime"; import { - mixedModeClientWorker, - MixedModeConnectionString, Plugin, ProxyNodeBinding, + remoteProxyClientWorker, + RemoteProxyConnectionString, } from "../shared"; export const DispatchNamespaceOptionsSchema = z.object({ @@ -14,7 +14,7 @@ export const DispatchNamespaceOptionsSchema = z.object({ .record( z.object({ namespace: z.string(), - mixedModeConnectionString: z.custom(), + remoteProxyConnectionString: z.custom(), }) ) .optional(), @@ -69,12 +69,15 @@ export const DISPATCH_NAMESPACE_PLUGIN: Plugin< return Object.entries(options.dispatchNamespaces).map(([name, config]) => { assert( - config.mixedModeConnectionString, - "Dispatch Namespace bindings only support Mixed Mode" + config.remoteProxyConnectionString, + "Dispatch Namespace bindings only support running remotely" ); return { name: `${DISPATCH_NAMESPACE_PLUGIN_NAME}:ns:${config.namespace}`, - worker: mixedModeClientWorker(config.mixedModeConnectionString, name), + worker: remoteProxyClientWorker( + config.remoteProxyConnectionString, + name + ), }; }); }, diff --git a/packages/miniflare/src/plugins/do/index.ts b/packages/miniflare/src/plugins/do/index.ts index f4f8baa2a893..9a90ef407937 100644 --- a/packages/miniflare/src/plugins/do/index.ts +++ b/packages/miniflare/src/plugins/do/index.ts @@ -5,10 +5,10 @@ import { getUserServiceName } from "../core"; import { getPersistPath, kUnsafeEphemeralUniqueKey, - MixedModeConnectionString, PersistenceSchema, Plugin, ProxyNodeBinding, + RemoteProxyConnectionString, UnsafeUniqueKey, } from "../shared"; @@ -36,8 +36,8 @@ export const DurableObjectsOptionsSchema = z.object({ .optional(), // Prevents the Durable Object being evicted. unsafePreventEviction: z.boolean().optional(), - mixedModeConnectionString: z - .custom() + remoteProxyConnectionString: z + .custom() .optional(), container: z.custom().optional(), }), @@ -60,7 +60,7 @@ export function normaliseDurableObject( enableSql: boolean | undefined; unsafeUniqueKey: UnsafeUniqueKey | undefined; unsafePreventEviction: boolean | undefined; - mixedModeConnectionString: MixedModeConnectionString | undefined; + remoteProxyConnectionString: RemoteProxyConnectionString | undefined; container: DOContainerOptions | undefined; } { const isObject = typeof designator === "object"; @@ -75,8 +75,8 @@ export function normaliseDurableObject( const unsafePreventEviction = isObject ? designator.unsafePreventEviction : undefined; - const mixedModeConnectionString = isObject - ? designator.mixedModeConnectionString + const remoteProxyConnectionString = isObject + ? designator.remoteProxyConnectionString : undefined; const container = isObject ? designator.container : undefined; return { @@ -86,7 +86,7 @@ export function normaliseDurableObject( enableSql, unsafeUniqueKey, unsafePreventEviction, - mixedModeConnectionString, + remoteProxyConnectionString, container, }; } diff --git a/packages/miniflare/src/plugins/images/index.ts b/packages/miniflare/src/plugins/images/index.ts index 8c0c843d6db9..0311761fcf94 100644 --- a/packages/miniflare/src/plugins/images/index.ts +++ b/packages/miniflare/src/plugins/images/index.ts @@ -1,10 +1,10 @@ import { z } from "zod"; import { CoreBindings, CoreHeaders } from "../../workers"; import { - mixedModeClientWorker, - MixedModeConnectionString, Plugin, ProxyNodeBinding, + remoteProxyClientWorker, + RemoteProxyConnectionString, WORKER_BINDING_SERVICE_LOOPBACK, } from "../shared"; @@ -21,7 +21,9 @@ const IMAGES_LOCAL_FETCHER = /* javascript */ ` const ImagesSchema = z.object({ binding: z.string(), - mixedModeConnectionString: z.custom().optional(), + remoteProxyConnectionString: z + .custom() + .optional(), }); export const ImagesOptionsSchema = z.object({ @@ -70,9 +72,9 @@ export const IMAGES_PLUGIN: Plugin = { return [ { name: `${IMAGES_PLUGIN_NAME}:${options.images.binding}`, - worker: options.images.mixedModeConnectionString - ? mixedModeClientWorker( - options.images.mixedModeConnectionString, + worker: options.images.remoteProxyConnectionString + ? remoteProxyClientWorker( + options.images.remoteProxyConnectionString, options.images.binding ) : { diff --git a/packages/miniflare/src/plugins/kv/index.ts b/packages/miniflare/src/plugins/kv/index.ts index ee2644186be5..dd5141d7ea24 100644 --- a/packages/miniflare/src/plugins/kv/index.ts +++ b/packages/miniflare/src/plugins/kv/index.ts @@ -12,14 +12,14 @@ import { getMiniflareObjectBindings, getPersistPath, migrateDatabase, - mixedModeClientWorker, - MixedModeConnectionString, namespaceEntries, namespaceKeys, objectEntryWorker, PersistenceSchema, Plugin, ProxyNodeBinding, + remoteProxyClientWorker, + RemoteProxyConnectionString, SERVICE_LOOPBACK, } from "../shared"; import { KV_PLUGIN_NAME } from "./constants"; @@ -37,8 +37,8 @@ export const KVOptionsSchema = z.object({ z.record( z.object({ id: z.string(), - mixedModeConnectionString: z - .custom() + remoteProxyConnectionString: z + .custom() .optional(), }) ), @@ -113,10 +113,10 @@ export const KV_PLUGIN: Plugin< const persist = sharedOptions.kvPersist; const namespaces = namespaceEntries(options.kvNamespaces); const services = namespaces.map( - ([name, { id, mixedModeConnectionString }]) => ({ + ([name, { id, remoteProxyConnectionString }]) => ({ name: `${SERVICE_NAMESPACE_PREFIX}:${id}`, - worker: mixedModeConnectionString - ? mixedModeClientWorker(mixedModeConnectionString, name) + worker: remoteProxyConnectionString + ? remoteProxyClientWorker(remoteProxyConnectionString, name) : objectEntryWorker(KV_NAMESPACE_OBJECT, id), }) ); diff --git a/packages/miniflare/src/plugins/mtls/index.ts b/packages/miniflare/src/plugins/mtls/index.ts index d2426caaff3c..aef1797519dd 100644 --- a/packages/miniflare/src/plugins/mtls/index.ts +++ b/packages/miniflare/src/plugins/mtls/index.ts @@ -1,15 +1,15 @@ import assert from "node:assert"; import { z } from "zod"; import { - mixedModeClientWorker, - MixedModeConnectionString, Plugin, ProxyNodeBinding, + remoteProxyClientWorker, + RemoteProxyConnectionString, } from "../shared"; const MtlsSchema = z.object({ certificate_id: z.string(), - mixedModeConnectionString: z.custom(), + remoteProxyConnectionString: z.custom(), }); export const MtlsOptionsSchema = z.object({ @@ -26,8 +26,11 @@ export const MTLS_PLUGIN: Plugin = { } return Object.entries(options.mtlsCertificates).map( - ([name, { certificate_id, mixedModeConnectionString }]) => { - assert(mixedModeConnectionString, "MTLS only supports Mixed Mode"); + ([name, { certificate_id, remoteProxyConnectionString }]) => { + assert( + remoteProxyConnectionString, + "MTLS only supports running remotely" + ); return { name, @@ -56,12 +59,15 @@ export const MTLS_PLUGIN: Plugin = { } return Object.entries(options.mtlsCertificates).map( - ([name, { certificate_id, mixedModeConnectionString }]) => { - assert(mixedModeConnectionString, "MTLS only supports Mixed Mode"); + ([name, { certificate_id, remoteProxyConnectionString }]) => { + assert( + remoteProxyConnectionString, + "MTLS only supports running remotely" + ); return { name: `${MTLS_PLUGIN_NAME}:${certificate_id}`, - worker: mixedModeClientWorker(mixedModeConnectionString, name), + worker: remoteProxyClientWorker(remoteProxyConnectionString, name), }; } ); diff --git a/packages/miniflare/src/plugins/queues/index.ts b/packages/miniflare/src/plugins/queues/index.ts index 3a8d127d21d3..9e46e96ad4fb 100644 --- a/packages/miniflare/src/plugins/queues/index.ts +++ b/packages/miniflare/src/plugins/queues/index.ts @@ -15,10 +15,10 @@ import { import { getUserServiceName } from "../core"; import { getMiniflareObjectBindings, - MixedModeConnectionString, objectEntryWorker, Plugin, ProxyNodeBinding, + RemoteProxyConnectionString, SERVICE_LOOPBACK, } from "../shared"; @@ -28,8 +28,8 @@ export const QueuesOptionsSchema = z.object({ z.record( QueueProducerOptionsSchema.merge( z.object({ - mixedModeConnectionString: z - .custom() + remoteProxyConnectionString: z + .custom() .optional(), }) ) diff --git a/packages/miniflare/src/plugins/r2/index.ts b/packages/miniflare/src/plugins/r2/index.ts index 8708c4d0c92d..2275b6d8c7fd 100644 --- a/packages/miniflare/src/plugins/r2/index.ts +++ b/packages/miniflare/src/plugins/r2/index.ts @@ -11,14 +11,14 @@ import { getMiniflareObjectBindings, getPersistPath, migrateDatabase, - mixedModeClientWorker, - MixedModeConnectionString, namespaceEntries, namespaceKeys, objectEntryWorker, PersistenceSchema, Plugin, ProxyNodeBinding, + remoteProxyClientWorker, + RemoteProxyConnectionString, SERVICE_LOOPBACK, } from "../shared"; @@ -29,8 +29,8 @@ export const R2OptionsSchema = z.object({ z.record( z.object({ id: z.string(), - mixedModeConnectionString: z - .custom() + remoteProxyConnectionString: z + .custom() .optional(), }) ), @@ -81,10 +81,10 @@ export const R2_PLUGIN: Plugin< const persist = sharedOptions.r2Persist; const buckets = namespaceEntries(options.r2Buckets); const services = buckets.map( - ([name, { id, mixedModeConnectionString }]) => ({ + ([name, { id, remoteProxyConnectionString }]) => ({ name: `${R2_BUCKET_SERVICE_PREFIX}:${id}`, - worker: mixedModeConnectionString - ? mixedModeClientWorker(mixedModeConnectionString, name) + worker: remoteProxyConnectionString + ? remoteProxyClientWorker(remoteProxyConnectionString, name) : objectEntryWorker(R2_BUCKET_OBJECT, id), }) ); diff --git a/packages/miniflare/src/plugins/shared/constants.ts b/packages/miniflare/src/plugins/shared/constants.ts index 26fa0e720596..683f0a69bb63 100644 --- a/packages/miniflare/src/plugins/shared/constants.ts +++ b/packages/miniflare/src/plugins/shared/constants.ts @@ -1,12 +1,12 @@ -import SCRIPT_MIXED_MODE_CLIENT from "worker:shared/mixed-mode-client"; import SCRIPT_OBJECT_ENTRY from "worker:shared/object-entry"; +import SCRIPT_REMOTE_PROXY_CLIENT from "worker:shared/remote-proxy-client"; import { Worker, Worker_Binding, Worker_Binding_DurableObjectNamespaceDesignator, } from "../../runtime"; import { CoreBindings, SharedBindings } from "../../workers"; -import { MixedModeConnectionString } from "."; +import { RemoteProxyConnectionString } from "."; export const SOCKET_ENTRY = "entry"; export const SOCKET_ENTRY_LOCAL = "entry:local"; @@ -73,8 +73,8 @@ export function objectEntryWorker( }; } -export function mixedModeClientWorker( - mixedModeConnectionString: MixedModeConnectionString, +export function remoteProxyClientWorker( + remoteProxyConnectionString: RemoteProxyConnectionString, binding: string ) { return { @@ -82,13 +82,13 @@ export function mixedModeClientWorker( modules: [ { name: "index.worker.js", - esModule: SCRIPT_MIXED_MODE_CLIENT(), + esModule: SCRIPT_REMOTE_PROXY_CLIENT(), }, ], bindings: [ { - name: "mixedModeConnectionString", - text: mixedModeConnectionString.href, + name: "remoteProxyConnectionString", + text: remoteProxyConnectionString.href, }, { name: "binding", diff --git a/packages/miniflare/src/plugins/shared/index.ts b/packages/miniflare/src/plugins/shared/index.ts index 32875017aac2..c070dec653c7 100644 --- a/packages/miniflare/src/plugins/shared/index.ts +++ b/packages/miniflare/src/plugins/shared/index.ts @@ -142,8 +142,8 @@ export function namespaceKeys( } } -export type MixedModeConnectionString = URL & { - __brand: "MixedModeConnectionString"; +export type RemoteProxyConnectionString = URL & { + __brand: "RemoteProxyConnectionString"; }; export function namespaceEntries( @@ -151,12 +151,15 @@ export function namespaceEntries( | Record< string, | string - | { id: string; mixedModeConnectionString?: MixedModeConnectionString } + | { + id: string; + remoteProxyConnectionString?: RemoteProxyConnectionString; + } > | string[] ): [ bindingName: string, - { id: string; mixedModeConnectionString?: MixedModeConnectionString }, + { id: string; remoteProxyConnectionString?: RemoteProxyConnectionString }, ][] { if (Array.isArray(namespaces)) { return namespaces.map((bindingName) => [bindingName, { id: bindingName }]); @@ -169,7 +172,7 @@ export function namespaceEntries( key, { id: value.id, - mixedModeConnectionString: value.mixedModeConnectionString, + remoteProxyConnectionString: value.remoteProxyConnectionString, }, ]; }); diff --git a/packages/miniflare/src/plugins/vectorize/index.ts b/packages/miniflare/src/plugins/vectorize/index.ts index 547e4be85f98..af21974ad728 100644 --- a/packages/miniflare/src/plugins/vectorize/index.ts +++ b/packages/miniflare/src/plugins/vectorize/index.ts @@ -1,15 +1,15 @@ import assert from "node:assert"; import { z } from "zod"; import { - mixedModeClientWorker, - MixedModeConnectionString, Plugin, ProxyNodeBinding, + remoteProxyClientWorker, + RemoteProxyConnectionString, } from "../shared"; const VectorizeSchema = z.object({ index_name: z.string(), - mixedModeConnectionString: z.custom(), + remoteProxyConnectionString: z.custom(), }); export const VectorizeOptionsSchema = z.object({ @@ -26,8 +26,11 @@ export const VECTORIZE_PLUGIN: Plugin = { } return Object.entries(options.vectorize).map( - ([name, { index_name, mixedModeConnectionString }]) => { - assert(mixedModeConnectionString, "Vectorize only supports Mixed Mode"); + ([name, { index_name, remoteProxyConnectionString }]) => { + assert( + remoteProxyConnectionString, + "Vectorize only supports running remotely" + ); return { name, @@ -73,12 +76,15 @@ export const VECTORIZE_PLUGIN: Plugin = { } return Object.entries(options.vectorize).map( - ([name, { mixedModeConnectionString }]) => { - assert(mixedModeConnectionString, "Vectorize only supports Mixed Mode"); + ([name, { remoteProxyConnectionString }]) => { + assert( + remoteProxyConnectionString, + "Vectorize only supports running remotely" + ); return { name: `${VECTORIZE_PLUGIN_NAME}:${name}`, - worker: mixedModeClientWorker(mixedModeConnectionString, name), + worker: remoteProxyClientWorker(remoteProxyConnectionString, name), }; } ); diff --git a/packages/miniflare/src/plugins/workflows/index.ts b/packages/miniflare/src/plugins/workflows/index.ts index 288b6c0532ab..8b6351debfaf 100644 --- a/packages/miniflare/src/plugins/workflows/index.ts +++ b/packages/miniflare/src/plugins/workflows/index.ts @@ -5,10 +5,10 @@ import { Service } from "../../runtime"; import { getUserServiceName } from "../core"; import { getPersistPath, - MixedModeConnectionString, PersistenceSchema, Plugin, ProxyNodeBinding, + RemoteProxyConnectionString, } from "../shared"; export const WorkflowsOptionsSchema = z.object({ @@ -18,8 +18,8 @@ export const WorkflowsOptionsSchema = z.object({ name: z.string(), className: z.string(), scriptName: z.string().optional(), - mixedModeConnectionString: z - .custom() + remoteProxyConnectionString: z + .custom() .optional(), }) ) diff --git a/packages/miniflare/src/shared/external-service.ts b/packages/miniflare/src/shared/external-service.ts index 8038243e4006..6318b50221a7 100644 --- a/packages/miniflare/src/shared/external-service.ts +++ b/packages/miniflare/src/shared/external-service.ts @@ -6,7 +6,7 @@ import { kCurrentWorker, ServiceDesignatorSchema, } from "../plugins/core"; -import { MixedModeConnectionString } from "../plugins/shared"; +import { RemoteProxyConnectionString } from "../plugins/shared"; import { HttpOptions, HttpOptions_Style, @@ -21,24 +21,24 @@ export function normaliseServiceDesignator( ): { serviceName: string | undefined; entrypoint: string | undefined; - mixedModeConnectionString: MixedModeConnectionString | undefined; + remoteProxyConnectionString: RemoteProxyConnectionString | undefined; } { let serviceName: string | undefined; let entrypoint: string | undefined; - let mixedModeConnectionString: MixedModeConnectionString | undefined; + let remoteProxyConnectionString: RemoteProxyConnectionString | undefined; if (typeof service === "string") { serviceName = service; } else if (typeof service === "object" && "name" in service) { serviceName = service.name !== kCurrentWorker ? service.name : undefined; entrypoint = service.entrypoint; - mixedModeConnectionString = service.mixedModeConnectionString; + remoteProxyConnectionString = service.remoteProxyConnectionString; } return { serviceName, entrypoint, - mixedModeConnectionString, + remoteProxyConnectionString, }; } diff --git a/packages/miniflare/src/workers/shared/mixed-mode-client.worker.ts b/packages/miniflare/src/workers/shared/remote-proxy-client.worker.ts similarity index 89% rename from packages/miniflare/src/workers/shared/mixed-mode-client.worker.ts rename to packages/miniflare/src/workers/shared/remote-proxy-client.worker.ts index a6ee9e15d9ea..47b2a62f8a9c 100644 --- a/packages/miniflare/src/workers/shared/mixed-mode-client.worker.ts +++ b/packages/miniflare/src/workers/shared/remote-proxy-client.worker.ts @@ -1,7 +1,7 @@ import { WorkerEntrypoint } from "cloudflare:workers"; export default class Client extends WorkerEntrypoint<{ - mixedModeConnectionString: string; + remoteProxyConnectionString: string; binding: string; }> { async fetch(request: Request) { @@ -21,6 +21,6 @@ export default class Client extends WorkerEntrypoint<{ headers: proxiedHeaders, }); - return fetch(this.env.mixedModeConnectionString, req); + return fetch(this.env.remoteProxyConnectionString, req); } } diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/auxiliary-worker/src/index.ts b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/auxiliary-worker/src/index.ts similarity index 100% rename from packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/auxiliary-worker/src/index.ts rename to packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/auxiliary-worker/src/index.ts diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/auxiliary-worker/wrangler.jsonc b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/auxiliary-worker/wrangler.jsonc similarity index 90% rename from packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/auxiliary-worker/wrangler.jsonc rename to packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/auxiliary-worker/wrangler.jsonc index e5caddb20dec..2b73422a4b25 100644 --- a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/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": "tmp-e2e-vite-plugin-mixed-mode-remote-worker-alt", - "remote": true, + "experimental_remote": true, }, ], } diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/entry-worker/src/index.ts b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/entry-worker/src/index.ts similarity index 100% rename from packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/entry-worker/src/index.ts rename to packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/entry-worker/src/index.ts diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/entry-worker/wrangler.jsonc b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/entry-worker/wrangler.jsonc similarity index 85% rename from packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/entry-worker/wrangler.jsonc rename to packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/entry-worker/wrangler.jsonc index ddff1e2d6ff8..b44d6ce7e63e 100644 --- a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/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-mixed-mode-auxiliary-worker", - "remote": false, + "experimental_remote": false, }, { "binding": "REMOTE_WORKER", "service": "tmp-e2e-vite-plugin-mixed-mode-remote-worker", - "remote": true, + "experimental_remote": true, }, ], } diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/package.json b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/package.json similarity index 92% rename from packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/package.json rename to packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/package.json index 21c5adf20c33..862f506103d5 100644 --- a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/package.json +++ b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/package.json @@ -1,5 +1,5 @@ { - "name": "cloudflare-vite-e2e-mixed-mode", + "name": "cloudflare-vite-e2e-remote-bindings", "version": "0.0.0", "private": true, "type": "module", diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/tsconfig.json b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/tsconfig.json similarity index 100% rename from packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/tsconfig.json rename to packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/tsconfig.json diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/tsconfig.node.json b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/tsconfig.node.json similarity index 100% rename from packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/tsconfig.node.json rename to packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/tsconfig.node.json diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/tsconfig.worker.json b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/tsconfig.worker.json similarity index 100% rename from packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/tsconfig.worker.json rename to packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/tsconfig.worker.json diff --git a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/vite.config.ts b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/vite.config.ts similarity index 89% rename from packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/vite.config.ts rename to packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/vite.config.ts index cacb944adbfb..b5332290d77f 100644 --- a/packages/vite-plugin-cloudflare/e2e/fixtures/mixed-mode/vite.config.ts +++ b/packages/vite-plugin-cloudflare/e2e/fixtures/remote-bindings/vite.config.ts @@ -12,7 +12,7 @@ export default defineConfig({ ], inspectorPort: false, persistState: false, - experimental: { mixedMode: true }, + experimental: { remoteBindings: true }, }), ], }); diff --git a/packages/vite-plugin-cloudflare/e2e/mixed-mode.test.ts b/packages/vite-plugin-cloudflare/e2e/remote-bindings.test.ts similarity index 78% rename from packages/vite-plugin-cloudflare/e2e/mixed-mode.test.ts rename to packages/vite-plugin-cloudflare/e2e/remote-bindings.test.ts index ae81c7e1b9ac..97af0f747488 100644 --- a/packages/vite-plugin-cloudflare/e2e/mixed-mode.test.ts +++ b/packages/vite-plugin-cloudflare/e2e/remote-bindings.test.ts @@ -3,13 +3,13 @@ import fs from "node:fs"; import { readFile, writeFile } from "node:fs/promises"; import os from "node:os"; import { setTimeout } from "node:timers/promises"; -import { afterAll, beforeAll, describe, test } from "vitest"; +import { afterAll, beforeAll, describe, test, vi } from "vitest"; import { fetchJson, runLongLived, seed, waitForReady } from "./helpers.js"; const isWindows = os.platform() === "win32"; const commands = ["dev", "buildAndPreview"] as const; -// These tests focus on mixed mode which require an authed connection to the CF API +// These tests focus on remote bindings which require an authed connection to the CF API // They are skipped if you have not provided the necessary account id and api token. describe .skipIf( @@ -19,12 +19,12 @@ describe ) // Note: the reload test applies changes to the fixture files, so we do want the // tests to run sequentially in order to avoid race conditions - .sequential("mixed-mode tests", () => { + .sequential("remote bindings tests", () => { const remoteWorkerName = "tmp-e2e-vite-plugin-mixed-mode-remote-worker"; const alternativeRemoteWorkerName = "tmp-e2e-vite-plugin-mixed-mode-remote-worker-alt"; - const projectPath = seed("mixed-mode", "pnpm"); + const projectPath = seed("remote-bindings", "pnpm"); beforeAll(() => { const tmp = fs.mkdtempSync(`${os.tmpdir()}/vite-plugin-e2e-tmp`); @@ -98,22 +98,30 @@ describe await setTimeout(500); - expect(await fetchJson(url)).toEqual({ - localWorkerResponseJson: { - remoteWorkerResponse: "Hello from an alternative remote worker", + await vi.waitFor( + async () => { + expect(await fetchJson(url)).toEqual({ + localWorkerResponseJson: { + remoteWorkerResponse: "Hello from an alternative remote worker", + }, + remoteWorkerResponseText: "Hello from a remote worker", + }); }, - remoteWorkerResponseText: "Hello from a remote worker", - }); + { timeout: 5_000, interval: 250 } + ); await writeFile(entryWorkerPath, entryWorkerContent, "utf8"); - await setTimeout(500); - - expect(await fetchJson(url)).toEqual({ - localWorkerResponse: { - remoteWorkerResponse: "Hello from an alternative remote worker", + await vi.waitFor( + async () => { + expect(await fetchJson(url)).toEqual({ + localWorkerResponse: { + remoteWorkerResponse: "Hello from an alternative remote worker", + }, + remoteWorkerResponse: "Hello from a remote worker", + }); }, - remoteWorkerResponse: "Hello from a remote worker", - }); + { timeout: 5_000, interval: 250 } + ); }); }); diff --git a/packages/vite-plugin-cloudflare/src/deploy-config.ts b/packages/vite-plugin-cloudflare/src/deploy-config.ts index 1756a0bbdc0b..bbf0c36cac8e 100644 --- a/packages/vite-plugin-cloudflare/src/deploy-config.ts +++ b/packages/vite-plugin-cloudflare/src/deploy-config.ts @@ -14,7 +14,7 @@ function getDeployConfigPath(root: string) { return path.resolve(root, ".wrangler", "deploy", "config.json"); } -export function getWorkerConfigs(root: string, mixedModeEnabled: boolean) { +export function getWorkerConfigs(root: string, remoteBindingsEnabled: boolean) { const deployConfigPath = getDeployConfigPath(root); const deployConfig = JSON.parse( fs.readFileSync(deployConfigPath, "utf-8") @@ -30,7 +30,7 @@ export function getWorkerConfigs(root: string, mixedModeEnabled: boolean) { ); return unstable_readConfig( { config: resolvedConfigPath }, - { experimental: { mixedModeEnabled } } + { experimental: { remoteBindingsEnabled } } ); }); } diff --git a/packages/vite-plugin-cloudflare/src/index.ts b/packages/vite-plugin-cloudflare/src/index.ts index b7489e158d98..261d18d85ae6 100644 --- a/packages/vite-plugin-cloudflare/src/index.ts +++ b/packages/vite-plugin-cloudflare/src/index.ts @@ -433,7 +433,7 @@ export function cloudflare(pluginConfig: PluginConfig = {}): vite.Plugin[] { async configurePreviewServer(vitePreviewServer) { const workerConfigs = getWorkerConfigs( vitePreviewServer.config.root, - pluginConfig.experimental?.mixedMode ?? false + pluginConfig.experimental?.remoteBindings ?? false ); const inputInspectorPort = await getInputInspectorPortOption( @@ -446,7 +446,7 @@ export function cloudflare(pluginConfig: PluginConfig = {}): vite.Plugin[] { vitePreviewServer, workerConfigs, pluginConfig.persistState ?? true, - !!pluginConfig.experimental?.mixedMode, + !!pluginConfig.experimental?.remoteBindings, inputInspectorPort ) ); @@ -772,7 +772,7 @@ export function cloudflare(pluginConfig: PluginConfig = {}): vite.Plugin[] { async configurePreviewServer(vitePreviewServer) { const workerConfigs = getWorkerConfigs( vitePreviewServer.config.root, - pluginConfig.experimental?.mixedMode ?? false + pluginConfig.experimental?.remoteBindings ?? false ); if (workerConfigs.length >= 1 && pluginConfig.inspectorPort !== false) { diff --git a/packages/vite-plugin-cloudflare/src/miniflare-options.ts b/packages/vite-plugin-cloudflare/src/miniflare-options.ts index e97f8d9c5f4e..3821042eefc6 100644 --- a/packages/vite-plugin-cloudflare/src/miniflare-options.ts +++ b/packages/vite-plugin-cloudflare/src/miniflare-options.ts @@ -14,7 +14,7 @@ import colors from "picocolors"; import { globSync } from "tinyglobby"; import * as vite from "vite"; import { - experimental_maybeStartOrUpdateMixedModeSession, + experimental_maybeStartOrUpdateRemoteProxySession, unstable_convertConfigBindingsToStartWorkerBindings, unstable_getMiniflareWorkerOptions, } from "wrangler"; @@ -37,7 +37,7 @@ import type { import type { MiniflareOptions, WorkerOptions } from "miniflare"; import type { FetchFunctionOptions } from "vite/module-runner"; import type { - Experimental_MixedModeSession, + Experimental_RemoteProxySession, SourcelessWorkerOptions, Unstable_Binding, Unstable_Config, @@ -222,11 +222,11 @@ function logUnknownTails( } } -/** Map that maps worker configPaths to their existing mixed mode session data (if any) */ -const mixedModeSessionsDataMap = new Map< +/** Map that maps worker configPaths to their existing remote proxy session data (if any) */ +const remoteProxySessionsDataMap = new Map< string, { - session: Experimental_MixedModeSession; + session: Experimental_RemoteProxySession; remoteBindings: Record; } | null >(); @@ -358,25 +358,25 @@ export async function getDevMiniflareOptions( workerConfig ); - const preExistingMixedModeSession = workerConfig.configPath - ? mixedModeSessionsDataMap.get(workerConfig.configPath) + const preExistingRemoteProxySession = workerConfig.configPath + ? remoteProxySessionsDataMap.get(workerConfig.configPath) : undefined; - const mixedModeSessionData = resolvedPluginConfig.experimental - .mixedMode - ? await experimental_maybeStartOrUpdateMixedModeSession( + const remoteProxySessionData = resolvedPluginConfig.experimental + .remoteBindings + ? await experimental_maybeStartOrUpdateRemoteProxySession( { name: workerConfig.name, bindings: bindings ?? {}, }, - preExistingMixedModeSession ?? null + preExistingRemoteProxySession ?? null ) : undefined; - if (workerConfig.configPath && mixedModeSessionData) { - mixedModeSessionsDataMap.set( + if (workerConfig.configPath && remoteProxySessionData) { + remoteProxySessionsDataMap.set( workerConfig.configPath, - mixedModeSessionData + remoteProxySessionData ); } @@ -387,9 +387,11 @@ export async function getDevMiniflareOptions( }, resolvedPluginConfig.cloudflareEnv, { - mixedModeConnectionString: - mixedModeSessionData?.session?.mixedModeConnectionString, - mixedModeEnabled: resolvedPluginConfig.experimental.mixedMode, + remoteProxyConnectionString: + remoteProxySessionData?.session + ?.remoteProxyConnectionString, + remoteBindingsEnabled: + resolvedPluginConfig.experimental.remoteBindings, } ); @@ -654,7 +656,7 @@ export async function getPreviewMiniflareOptions( vitePreviewServer: vite.PreviewServer, workerConfigs: Unstable_Config[], persistState: PersistState, - mixedModeEnabled: boolean, + remoteBindingsEnabled: boolean, inspectorPort: number | false ): Promise { const resolvedViteConfig = vitePreviewServer.config; @@ -664,24 +666,24 @@ export async function getPreviewMiniflareOptions( const bindings = unstable_convertConfigBindingsToStartWorkerBindings(workerConfig); - const preExistingMixedModeSessionData = workerConfig.configPath - ? mixedModeSessionsDataMap.get(workerConfig.configPath) + const preExistingRemoteProxySessionData = workerConfig.configPath + ? remoteProxySessionsDataMap.get(workerConfig.configPath) : undefined; - const mixedModeSessionData = mixedModeEnabled - ? await experimental_maybeStartOrUpdateMixedModeSession( + const remoteProxySessionData = remoteBindingsEnabled + ? await experimental_maybeStartOrUpdateRemoteProxySession( { name: workerConfig.name, bindings: bindings ?? {}, }, - preExistingMixedModeSessionData ?? null + preExistingRemoteProxySessionData ?? null ) : undefined; - if (workerConfig.configPath && mixedModeSessionData) { - mixedModeSessionsDataMap.set( + if (workerConfig.configPath && remoteProxySessionData) { + remoteProxySessionsDataMap.set( workerConfig.configPath, - mixedModeSessionData + remoteProxySessionData ); } @@ -689,9 +691,9 @@ export async function getPreviewMiniflareOptions( workerConfig, undefined, { - mixedModeConnectionString: - mixedModeSessionData?.session?.mixedModeConnectionString, - mixedModeEnabled, + remoteProxyConnectionString: + remoteProxySessionData?.session?.remoteProxyConnectionString, + remoteBindingsEnabled, } ); diff --git a/packages/vite-plugin-cloudflare/src/plugin-config.ts b/packages/vite-plugin-cloudflare/src/plugin-config.ts index f432a7924fca..a29a7dfb972e 100644 --- a/packages/vite-plugin-cloudflare/src/plugin-config.ts +++ b/packages/vite-plugin-cloudflare/src/plugin-config.ts @@ -36,8 +36,8 @@ export interface PluginConfig extends EntryWorkerConfig { experimental?: { /** Experimental support for handling the _headers and _redirects files during Vite dev mode. */ headersAndRedirectsDevModeSupport?: boolean; - /** Experimental support for mixed mode (where bindings configured with `remote: true` access remote resources). */ - mixedMode?: boolean; + /** Experimental support for remote bindings (where bindings configured with `experimental_experimental_remote: true` access remote resources). */ + remoteBindings?: boolean; }; } @@ -58,7 +58,7 @@ interface BasePluginConfig { experimental: { /** Experimental support for handling the _headers and _redirects files during Vite dev mode. */ headersAndRedirectsDevModeSupport?: boolean; - mixedMode?: boolean; + remoteBindings?: boolean; }; } @@ -111,7 +111,7 @@ export function resolvePluginConfig( const entryWorkerResolvedConfig = getWorkerConfig( entryWorkerConfigPath, cloudflareEnv, - pluginConfig.experimental?.mixedMode ?? false, + pluginConfig.experimental?.remoteBindings ?? false, { visitedConfigPaths: configPaths, isEntryWorker: true, @@ -161,7 +161,7 @@ export function resolvePluginConfig( const workerResolvedConfig = getWorkerConfig( workerConfigPath, cloudflareEnv, - pluginConfig.experimental?.mixedMode ?? false, + pluginConfig.experimental?.remoteBindings ?? false, { visitedConfigPaths: configPaths, } diff --git a/packages/vite-plugin-cloudflare/src/workers-configs.ts b/packages/vite-plugin-cloudflare/src/workers-configs.ts index 050ab402f0d9..a5f7706a31d2 100644 --- a/packages/vite-plugin-cloudflare/src/workers-configs.ts +++ b/packages/vite-plugin-cloudflare/src/workers-configs.ts @@ -113,7 +113,7 @@ const nullableNonApplicable = [ function readWorkerConfig( configPath: string, env: string | undefined, - mixedModeEnabled: boolean + remoteBindingsEnabled: boolean ): { raw: RawWorkerConfig; config: SanitizedWorkerConfig; @@ -126,7 +126,7 @@ function readWorkerConfig( const config: Optional = unstable_readConfig( { config: configPath, env }, - { experimental: { mixedModeEnabled } } + { experimental: { remoteBindingsEnabled } } ); const raw = structuredClone(config) as RawWorkerConfig; @@ -279,7 +279,7 @@ function missingFieldErrorMessage( export function getWorkerConfig( configPath: string, env: string | undefined, - mixedModeEnabled: boolean, + remoteBindingsEnabled: boolean, opts?: { visitedConfigPaths?: Set; isEntryWorker?: boolean; @@ -292,7 +292,7 @@ export function getWorkerConfig( const { raw, config, nonApplicable } = readWorkerConfig( configPath, env, - mixedModeEnabled + remoteBindingsEnabled ); opts?.visitedConfigPaths?.add(configPath); diff --git a/packages/vitest-pool-workers/src/pool/config.ts b/packages/vitest-pool-workers/src/pool/config.ts index ebf13c9cbb76..7bc5e6428f84 100644 --- a/packages/vitest-pool-workers/src/pool/config.ts +++ b/packages/vitest-pool-workers/src/pool/config.ts @@ -13,7 +13,10 @@ 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_MixedModeSession, Unstable_Binding } from "wrangler"; +import type { + Experimental_RemoteProxySession, + Unstable_Binding, +} from "wrangler"; import type { ParseParams, ZodError } from "zod"; export interface WorkersConfigPluginAPI { @@ -45,10 +48,10 @@ const WorkersPoolOptionsSchema = z.object({ */ isolatedStorage: z.boolean().default(true), /** - * Enables experimental mixed mode to access remote resources configured - * with `remote: true` in the wrangler configuration file. + * Enables experimental remote bindings to access remote resources configured + * with `experimental_experimental_remote: true` in the wrangler configuration file. */ - experimental_mixedMode: z.boolean().optional(), + experimental_remoteBindings: z.boolean().optional(), /** * 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 @@ -177,11 +180,11 @@ function filterTails( }); } -/** Map that maps worker configPaths to their existing mixed mode session data (if any) */ -const mixedModeSessionsDataMap = new Map< +/** Map that maps worker configPaths to their existing remote proxy session data (if any) */ +const remoteProxySessionsDataMap = new Map< string, { - session: Experimental_MixedModeSession; + session: Experimental_RemoteProxySession; remoteBindings: Record; } | null >(); @@ -250,21 +253,21 @@ async function parseCustomPoolOptions( // Lazily import `wrangler` if and when we need it const wrangler = await import("wrangler"); - const preExistingMixedModeSessionData = options.wrangler?.configPath - ? mixedModeSessionsDataMap.get(options.wrangler.configPath) + const preExistingRemoteProxySessionData = options.wrangler?.configPath + ? remoteProxySessionsDataMap.get(options.wrangler.configPath) : undefined; - const mixedModeSessionData = options.experimental_mixedMode - ? await wrangler.experimental_maybeStartOrUpdateMixedModeSession( + const remoteProxySessionData = options.experimental_remoteBindings + ? await wrangler.experimental_maybeStartOrUpdateRemoteProxySession( configPath, - preExistingMixedModeSessionData ?? null + preExistingRemoteProxySessionData ?? null ) : null; - if (options.wrangler?.configPath && mixedModeSessionData) { - mixedModeSessionsDataMap.set( + if (options.wrangler?.configPath && remoteProxySessionData) { + remoteProxySessionsDataMap.set( options.wrangler.configPath, - mixedModeSessionData + remoteProxySessionData ); } @@ -275,8 +278,9 @@ async function parseCustomPoolOptions( { imagesLocalMode: true, overrides: { assets: options.miniflare.assets }, - mixedModeConnectionString: - mixedModeSessionData?.session?.mixedModeConnectionString, + remoteBindingsEnabled: options.experimental_remoteBindings, + remoteProxyConnectionString: + remoteProxySessionData?.session?.remoteProxyConnectionString, } ); diff --git a/packages/wrangler/e2e/dev-mixed-mode.test.ts b/packages/wrangler/e2e/dev-remote-bindings.test.ts similarity index 90% rename from packages/wrangler/e2e/dev-mixed-mode.test.ts rename to packages/wrangler/e2e/dev-remote-bindings.test.ts index 065de8b58e41..b64c32a87801 100644 --- a/packages/wrangler/e2e/dev-mixed-mode.test.ts +++ b/packages/wrangler/e2e/dev-remote-bindings.test.ts @@ -10,13 +10,15 @@ import { generateResourceName } from "./helpers/generate-resource-name"; import { normalizeOutput } from "./helpers/normalize"; import { makeRoot, seed } from "./helpers/setup"; -describe("wrangler dev - mixed mode", () => { +describe("wrangler dev - remote bindings", () => { const remoteWorkerName = generateResourceName(); const alternativeRemoteWorkerName = generateResourceName(); const helper = new WranglerE2ETestHelper(); beforeAll(async () => { - await helper.seed(resolve(__dirname, "./seed-files/mixed-mode-workers")); + await helper.seed( + resolve(__dirname, "./seed-files/remote-binding-workers") + ); await helper.seed({ "remote-worker.js": dedent/* javascript */ ` @@ -60,13 +62,13 @@ describe("wrangler dev - mixed mode", () => { { binding: "REMOTE_WORKER", service: remoteWorkerName, - remote: true, + experimental_remote: true, }, ], }), }); - const worker = helper.runLongLived("wrangler dev --x-mixed-mode"); + const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); const { url } = await worker.waitForReady(); @@ -88,13 +90,13 @@ describe("wrangler dev - mixed mode", () => { { binding: "REMOTE_WORKER", service: remoteWorkerName, - remote: true, + experimental_remote: true, }, ], }), }); - const worker = helper.runLongLived("wrangler dev --x-mixed-mode"); + const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); const { url } = await worker.waitForReady(); @@ -150,7 +152,7 @@ describe("wrangler dev - mixed mode", () => { }), }); - const worker = helper.runLongLived("wrangler dev --x-mixed-mode"); + const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); const { url } = await worker.waitForReady(); @@ -174,7 +176,7 @@ describe("wrangler dev - mixed mode", () => { }), }); - const worker = helper.runLongLived("wrangler dev --x-mixed-mode"); + const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); const { url } = await worker.waitForReady(); @@ -188,7 +190,7 @@ describe("wrangler dev - mixed mode", () => { Binding Resource Mode env.AI AI remote [wrangler:info] Ready on http://: - ▲ [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. + ▲ [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. ⎔ Starting local server... [wrangler:info] GET / 200 OK (TIMINGS)" `); @@ -205,13 +207,13 @@ describe("wrangler dev - mixed mode", () => { { binding: "REMOTE_WORKER", service: "non-existent-service-binding", - remote: true, + experimental_remote: true, }, ], }), }); - const worker = helper.runLongLived("wrangler dev --x-mixed-mode"); + const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); await worker.waitForReady(); @@ -234,13 +236,13 @@ describe("wrangler dev - mixed mode", () => { { binding: "KV_BINDING", id: "non-existent-kv", - remote: true, + experimental_remote: true, }, ], }), }); - const worker = helper.runLongLived("wrangler dev --x-mixed-mode"); + const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); await worker.waitForReady(); @@ -270,7 +272,7 @@ describe("wrangler dev - mixed mode", () => { { binding: "REMOTE_WORKER", service: remoteWorkerName, - remote: true, + experimental_remote: true, }, ], }), @@ -286,7 +288,7 @@ describe("wrangler dev - mixed mode", () => { // Note: we use the same binding name but bound to a difference service binding: "REMOTE_WORKER", service: alternativeRemoteWorkerName, - remote: true, + experimental_remote: true, }, ], }), @@ -300,7 +302,7 @@ describe("wrangler dev - mixed mode", () => { }); const worker = helper.runLongLived( - `wrangler dev --x-mixed-mode -c wrangler.json -c ${localTest}/wrangler.json` + `wrangler dev --x-remote-bindings -c wrangler.json -c ${localTest}/wrangler.json` ); const { url } = await worker.waitForReady(); diff --git a/packages/wrangler/e2e/miniflare-mixed-mode-resources.test.ts b/packages/wrangler/e2e/miniflare-remote-resources.test.ts similarity index 84% rename from packages/wrangler/e2e/miniflare-mixed-mode-resources.test.ts rename to packages/wrangler/e2e/miniflare-remote-resources.test.ts index df2971791b6f..51dcad36f7e5 100644 --- a/packages/wrangler/e2e/miniflare-mixed-mode-resources.test.ts +++ b/packages/wrangler/e2e/miniflare-remote-resources.test.ts @@ -9,19 +9,19 @@ import { } from "./helpers/cert"; import { WranglerE2ETestHelper } from "./helpers/e2e-wrangler-test"; import { generateResourceName } from "./helpers/generate-resource-name"; -import type { startMixedModeSession } from "../src/api"; +import type { startRemoteProxySession } from "../src/api"; import type { RawConfig } from "../src/config"; -import type { MixedModeConnectionString, WorkerOptions } from "miniflare"; +import type { RemoteProxyConnectionString, WorkerOptions } from "miniflare"; import type { ExpectStatic } from "vitest"; type TestCase = { name: string; scriptPath: string; - mixedModeSessionConfig: - | Parameters - | ((setup: T) => Parameters); + remoteProxySessionConfig: + | Parameters + | ((setup: T) => Parameters); miniflareConfig: ( - connection: MixedModeConnectionString, + connection: RemoteProxyConnectionString, setup: T ) => Partial; setup?: (helper: WranglerE2ETestHelper) => Promise | T; @@ -31,7 +31,7 @@ const testCases: TestCase[] = [ { name: "AI", scriptPath: "ai.js", - mixedModeSessionConfig: [ + remoteProxySessionConfig: [ { AI: { type: "ai", @@ -41,7 +41,7 @@ const testCases: TestCase[] = [ miniflareConfig: (connection) => ({ ai: { binding: "AI", - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, }), matches: [expect.stringMatching(/This is a response from Workers AI/)], @@ -49,7 +49,7 @@ const testCases: TestCase[] = [ { name: "Browser", scriptPath: "browser.js", - mixedModeSessionConfig: [ + remoteProxySessionConfig: [ { BROWSER: { type: "browser", @@ -59,7 +59,7 @@ const testCases: TestCase[] = [ miniflareConfig: (connection) => ({ browserRendering: { binding: "BROWSER", - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, }), matches: [expect.stringMatching(/sessionId/)], @@ -92,7 +92,7 @@ const testCases: TestCase[] = [ }); return targetWorkerName; }, - mixedModeSessionConfig: (target) => [ + remoteProxySessionConfig: (target) => [ { SERVICE: { type: "service", @@ -109,12 +109,12 @@ const testCases: TestCase[] = [ serviceBindings: { SERVICE: { name: target, - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, SERVICE_WITH_ENTRYPOINT: { name: target, entrypoint: "CustomEntrypoint", - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, }, }), @@ -137,7 +137,7 @@ const testCases: TestCase[] = [ ); return ns; }, - mixedModeSessionConfig: (ns) => [ + remoteProxySessionConfig: (ns) => [ { KV_BINDING: { type: "kv_namespace", @@ -149,7 +149,7 @@ const testCases: TestCase[] = [ kvNamespaces: { KV_BINDING: { id: ns, - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, }, }), @@ -173,7 +173,7 @@ const testCases: TestCase[] = [ }); return name; }, - mixedModeSessionConfig: (name) => [ + remoteProxySessionConfig: (name) => [ { R2_BINDING: { type: "r2_bucket", @@ -185,7 +185,7 @@ const testCases: TestCase[] = [ r2Buckets: { R2_BINDING: { id: name, - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, }, }), @@ -209,7 +209,7 @@ const testCases: TestCase[] = [ ); return id; }, - mixedModeSessionConfig: (id) => [ + remoteProxySessionConfig: (id) => [ { DB: { type: "d1", @@ -221,7 +221,7 @@ const testCases: TestCase[] = [ d1Databases: { DB: { id: id, - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, }, }), @@ -238,7 +238,7 @@ const testCases: TestCase[] = [ ); return name; }, - mixedModeSessionConfig: (name) => [ + remoteProxySessionConfig: (name) => [ { VECTORIZE_BINDING: { type: "vectorize", @@ -250,7 +250,7 @@ const testCases: TestCase[] = [ vectorize: { VECTORIZE_BINDING: { index_name: name, - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, }, }), @@ -263,7 +263,7 @@ const testCases: TestCase[] = [ { name: "Images", scriptPath: "images.js", - mixedModeSessionConfig: [ + remoteProxySessionConfig: [ { IMAGES: { type: "images", @@ -273,7 +273,7 @@ const testCases: TestCase[] = [ miniflareConfig: (connection) => ({ images: { binding: "IMAGES", - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, }), matches: [expect.stringContaining(`image/avif`)], @@ -300,7 +300,7 @@ const testCases: TestCase[] = [ return namespace; }, - mixedModeSessionConfig: (namespace) => [ + remoteProxySessionConfig: (namespace) => [ { DISPATCH: { type: "dispatch_namespace", @@ -312,7 +312,7 @@ const testCases: TestCase[] = [ dispatchNamespaces: { DISPATCH: { namespace: namespace, - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, }, }), @@ -377,7 +377,7 @@ const mtlsTest: TestCase<{ certificateId: string; workerName: string }> = { return { certificateId, workerName }; }, - mixedModeSessionConfig: ({ certificateId, workerName }) => [ + remoteProxySessionConfig: ({ certificateId, workerName }) => [ { MTLS: { type: "mtls_certificate", @@ -392,7 +392,7 @@ const mtlsTest: TestCase<{ certificateId: string; workerName: string }> = { mtlsCertificates: { MTLS: { certificate_id: certificateId, - mixedModeConnectionString: connection, + remoteProxyConnectionString: connection, }, }, }), @@ -418,7 +418,7 @@ describe.each([...testCases, mtlsTest])("Mixed Mode for $name", (testCase) => { { retry: 0, fails: true }, async () => { await runTestCase(testCase as TestCase, helper, { - disableMixedMode: true, + disableRemoteBindings: true, }); } ); @@ -427,28 +427,31 @@ describe.each([...testCases, mtlsTest])("Mixed Mode for $name", (testCase) => { async function runTestCase( testCase: TestCase, helper: WranglerE2ETestHelper, - { disableMixedMode } = { disableMixedMode: false } + { disableRemoteBindings } = { disableRemoteBindings: false } ) { - const { experimental_startMixedModeSession } = await helper.importWrangler(); + const { experimental_startRemoteProxySession } = + await helper.importWrangler(); const { Miniflare } = await helper.importMiniflare(); - await helper.seed(path.resolve(__dirname, "./seed-files/mixed-mode-workers")); + await helper.seed( + path.resolve(__dirname, "./seed-files/remote-binding-workers") + ); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const setupResult = (await testCase.setup?.(helper))!; - const mixedModeSessionConfig = - typeof testCase.mixedModeSessionConfig === "function" - ? testCase.mixedModeSessionConfig(setupResult) - : testCase.mixedModeSessionConfig; + const remoteProxySessionConfig = + typeof testCase.remoteProxySessionConfig === "function" + ? testCase.remoteProxySessionConfig(setupResult) + : testCase.remoteProxySessionConfig; - const mixedModeSession = await experimental_startMixedModeSession( - ...mixedModeSessionConfig + const remoteProxySession = await experimental_startRemoteProxySession( + ...remoteProxySessionConfig ); - const miniflareConfig = disableMixedMode + const miniflareConfig = disableRemoteBindings ? // @ts-expect-error Deliberately passing in undefined here to turn off Mixed Mode testCase.miniflareConfig(undefined) : testCase.miniflareConfig( - mixedModeSession.mixedModeConnectionString, + remoteProxySession.remoteProxyConnectionString, setupResult ); diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/ai.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/ai.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/ai.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/ai.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/browser.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/browser.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/browser.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/browser.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/d1.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/d1.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/d1.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/d1.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/dispatch-namespace.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/dispatch-namespace.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/dispatch-namespace.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/dispatch-namespace.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/images.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/images.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/images.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/images.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/kv.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/kv.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/kv.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/kv.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/local-and-remote-service-bindings.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/local-and-remote-service-bindings.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/local-and-remote-service-bindings.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/local-and-remote-service-bindings.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/local-service-binding-and-remote-ai.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/local-service-binding-and-remote-ai.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/local-service-binding-and-remote-ai.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/local-service-binding-and-remote-ai.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/mtls.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/mtls.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/mtls.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/mtls.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/r2.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/r2.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/r2.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/r2.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/service-binding.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/service-binding.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/service-binding.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/service-binding.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/simple-service-binding.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/simple-service-binding.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/simple-service-binding.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/simple-service-binding.js diff --git a/packages/wrangler/e2e/seed-files/mixed-mode-workers/vectorize.js b/packages/wrangler/e2e/seed-files/remote-binding-workers/vectorize.js similarity index 100% rename from packages/wrangler/e2e/seed-files/mixed-mode-workers/vectorize.js rename to packages/wrangler/e2e/seed-files/remote-binding-workers/vectorize.js diff --git a/packages/wrangler/e2e/start-worker-mixed-mode.test.ts b/packages/wrangler/e2e/start-worker-remote-bindings.test.ts similarity index 88% rename from packages/wrangler/e2e/start-worker-mixed-mode.test.ts rename to packages/wrangler/e2e/start-worker-remote-bindings.test.ts index 137ff9f88e06..ec605734359b 100644 --- a/packages/wrangler/e2e/start-worker-mixed-mode.test.ts +++ b/packages/wrangler/e2e/start-worker-remote-bindings.test.ts @@ -6,12 +6,14 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest"; import { WranglerE2ETestHelper } from "./helpers/e2e-wrangler-test"; import { generateResourceName } from "./helpers/generate-resource-name"; -describe("startWorker - mixed mode", () => { +describe("startWorker - remote bindings", () => { const remoteWorkerName = generateResourceName(); const helper = new WranglerE2ETestHelper(); beforeAll(async () => { - await helper.seed(resolve(__dirname, "./seed-files/mixed-mode-workers")); + await helper.seed( + resolve(__dirname, "./seed-files/remote-binding-workers") + ); await helper.seed({ "remote-worker.js": dedent/* javascript */ ` export default { @@ -31,11 +33,11 @@ describe("startWorker - mixed mode", () => { }); describe.each([true, false])( - `with experimentalMixedMode %s`, - (experimentalMixedMode) => { + `with experimentalRemoteBindings %s`, + (experimentalRemoteBindings) => { const testOpts: NonNullable[1]> = { - fails: !experimentalMixedMode, - retry: !experimentalMixedMode ? 0 : undefined, + fails: !experimentalRemoteBindings, + retry: !experimentalRemoteBindings ? 0 : undefined, }; it("allows connecting to a remote worker", testOpts, async () => { @@ -48,7 +50,7 @@ describe("startWorker - mixed mode", () => { { binding: "REMOTE_WORKER", service: remoteWorkerName, - remote: true, + experimental_remote: true, }, ], }), @@ -58,7 +60,7 @@ describe("startWorker - mixed mode", () => { const worker = await unstable_startWorker({ config: `${helper.tmpPath}/wrangler.json`, dev: { - experimentalMixedMode, + experimentalRemoteBindings, }, }); @@ -83,7 +85,7 @@ describe("startWorker - mixed mode", () => { { binding: "REMOTE_WORKER", service: remoteWorkerName, - remote: true, + experimental_remote: true, }, ], }), @@ -94,7 +96,7 @@ describe("startWorker - mixed mode", () => { const worker = await unstable_startWorker({ config: `${helper.tmpPath}/wrangler.json`, dev: { - experimentalMixedMode, + experimentalRemoteBindings, }, }); diff --git a/packages/wrangler/e2e/wrangler-mixed-mode-resources.test.ts b/packages/wrangler/e2e/wrangler-remote-resources.test.ts similarity index 77% rename from packages/wrangler/e2e/wrangler-mixed-mode-resources.test.ts rename to packages/wrangler/e2e/wrangler-remote-resources.test.ts index 61d3510c0660..7616a8e2dd41 100644 --- a/packages/wrangler/e2e/wrangler-mixed-mode-resources.test.ts +++ b/packages/wrangler/e2e/wrangler-remote-resources.test.ts @@ -23,8 +23,8 @@ type TestCase = { setup?: (helper: WranglerE2ETestHelper) => Promise | T; generateWranglerConfig: (setupResult: T) => RawConfig; expectedResponseMatch: string | RegExp; - // Flag for resources that can work without mixed mode - worksWithoutMixedMode?: boolean; + // Flag for resources that can work without remote bindings opt-in + worksWithoutRemoteBindings?: boolean; }; const testCases: TestCase>[] = [ @@ -78,13 +78,13 @@ const testCases: TestCase>[] = [ { binding: "SERVICE", service: targetWorkerName, - remote: true, + experimental_remote: true, }, { binding: "SERVICE_WITH_ENTRYPOINT", service: targetWorkerName, entrypoint: "CustomEntrypoint", - remote: true, + experimental_remote: true, }, ], }), @@ -102,12 +102,12 @@ const testCases: TestCase>[] = [ compatibility_date: "2025-01-01", ai: { binding: "AI", - remote: true, + experimental_remote: true, }, }), expectedResponseMatch: "This is a response from Workers AI", - // AI bindings work without mixed mode flag - worksWithoutMixedMode: true, + // AI bindings work without opt in flag + worksWithoutRemoteBindings: true, }, { name: "Browser", @@ -118,7 +118,7 @@ const testCases: TestCase>[] = [ compatibility_date: "2025-01-01", browser: { binding: "BROWSER", - remote: true, + experimental_remote: true, }, }), expectedResponseMatch: /sessionId/, @@ -132,12 +132,12 @@ const testCases: TestCase>[] = [ compatibility_date: "2025-01-01", images: { binding: "IMAGES", - remote: true, + experimental_remote: true, }, }), expectedResponseMatch: "image/avif", - // The Images binding "works" without mixed mode because the current default is an older mixed-mode-style implementation - worksWithoutMixedMode: true, + // The Images binding "works" without opt in flag because the current default is an older remote binding implementation + worksWithoutRemoteBindings: true, }, { name: "Vectorize", @@ -158,7 +158,7 @@ const testCases: TestCase>[] = [ { binding: "VECTORIZE_BINDING", index_name: name, - remote: true, + experimental_remote: true, }, ], }), @@ -194,7 +194,7 @@ const testCases: TestCase>[] = [ { binding: "DISPATCH", namespace: namespace, - remote: true, + experimental_remote: true, }, ], }), @@ -218,7 +218,7 @@ const testCases: TestCase>[] = [ { binding: "KV_BINDING", id: namespaceId, - remote: true, + experimental_remote: true, }, ], }), @@ -248,7 +248,7 @@ const testCases: TestCase>[] = [ { binding: "R2_BINDING", bucket_name: bucketName, - remote: true, + experimental_remote: true, }, ], }), @@ -279,7 +279,7 @@ const testCases: TestCase>[] = [ binding: "DB", database_id: id, database_name: name, - remote: true, + experimental_remote: true, }, ], }), @@ -295,14 +295,14 @@ describe("Wrangler Mixed Mode E2E Tests", () => { helper = new WranglerE2ETestHelper(); }); - it("works with mixed mode enabled", async () => { + it("works with remote bindings enabled", async () => { await helper.seed( - path.resolve(__dirname, "./seed-files/mixed-mode-workers") + path.resolve(__dirname, "./seed-files/remote-binding-workers") ); await writeWranglerConfig(testCase, helper); - const worker = helper.runLongLived("wrangler dev --x-mixed-mode"); + const worker = helper.runLongLived("wrangler dev --x-remote-bindings"); const { url } = await worker.waitForReady(); @@ -310,13 +310,13 @@ describe("Wrangler Mixed Mode E2E Tests", () => { expect(response).toMatch(testCase.expectedResponseMatch); }); - it.skipIf(testCase.worksWithoutMixedMode)( - "fails when mixed mode is disabled", + 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, "./seed-files/mixed-mode-workers") + path.resolve(__dirname, "./seed-files/remote-binding-workers") ); await writeWranglerConfig(testCase, helper); @@ -331,57 +331,60 @@ describe("Wrangler Mixed Mode E2E Tests", () => { ); }); - describe.sequential("Sequential mixed mode tests with worker reloads", () => { - let worker: WranglerLongLivedCommand; - let helper: WranglerE2ETestHelper; + describe.sequential( + "Sequential remote bindings tests with worker reloads", + () => { + let worker: WranglerLongLivedCommand; + let helper: WranglerE2ETestHelper; - let url: string; + let url: string; - beforeAll(async () => { - helper = new WranglerE2ETestHelper(); - await helper.seed( - path.resolve(__dirname, "./seed-files/mixed-mode-workers") - ); + beforeAll(async () => { + helper = new WranglerE2ETestHelper(); + await helper.seed( + path.resolve(__dirname, "./seed-files/remote-binding-workers") + ); - await helper.seed({ - "wrangler.json": JSON.stringify( - { - name: "mixed-mode-sequential-test", - main: "placeholder.js", - compatibility_date: "2025-01-01", - }, - null, - 2 - ), - "placeholder.js": - "export default { fetch() { return new Response('Ready to start tests') } }", - }); + await helper.seed({ + "wrangler.json": JSON.stringify( + { + name: "mixed-mode-sequential-test", + main: "placeholder.js", + compatibility_date: "2025-01-01", + }, + null, + 2 + ), + "placeholder.js": + "export default { fetch() { return new Response('Ready to start tests') } }", + }); - worker = helper.runLongLived("wrangler dev --x-mixed-mode", { - stopOnTestFinished: false, - }); + worker = helper.runLongLived("wrangler dev --x-remote-bindings", { + stopOnTestFinished: false, + }); - const ready = await worker.waitForReady(); - url = ready.url; - }); - afterAll(async () => { - await worker.stop(); - }); + const ready = await worker.waitForReady(); + url = ready.url; + }); + afterAll(async () => { + await worker.stop(); + }); - it.each(testCases)("$name with worker reload", async (testCase) => { - await writeWranglerConfig(testCase, helper); + it.each(testCases)("$name with worker reload", async (testCase) => { + await writeWranglerConfig(testCase, helper); - await worker.waitForReload(); + await worker.waitForReload(); - await vi.waitFor( - async () => { - const response = await fetchText(url); - expect(response).toMatch(testCase.expectedResponseMatch); - }, - { interval: 1_000, timeout: 40_000 } - ); - }); - }); + await vi.waitFor( + async () => { + const response = await fetchText(url); + expect(response).toMatch(testCase.expectedResponseMatch); + }, + { interval: 1_000, timeout: 40_000 } + ); + }); + } + ); }); async function writeWranglerConfig( diff --git a/packages/wrangler/src/__tests__/config/configuration.test.ts b/packages/wrangler/src/__tests__/config/configuration.test.ts index f9c201ecf6a6..ad4cda4f5c79 100644 --- a/packages/wrangler/src/__tests__/config/configuration.test.ts +++ b/packages/wrangler/src/__tests__/config/configuration.test.ts @@ -2405,7 +2405,7 @@ describe("normalizeAndValidateConfig()", () => { { RESOURCES_PROVISION: true, MULTIWORKER: false, - MIXED_MODE: false, + REMOTE_BINDINGS: false, }, () => normalizeAndValidateConfig( @@ -2561,7 +2561,7 @@ describe("normalizeAndValidateConfig()", () => { { RESOURCES_PROVISION: true, MULTIWORKER: false, - MIXED_MODE: false, + REMOTE_BINDINGS: false, }, () => normalizeAndValidateConfig( @@ -2899,7 +2899,7 @@ describe("normalizeAndValidateConfig()", () => { { RESOURCES_PROVISION: true, MULTIWORKER: false, - MIXED_MODE: false, + REMOTE_BINDINGS: false, }, () => normalizeAndValidateConfig( @@ -6368,22 +6368,22 @@ describe("normalizeAndValidateConfig()", () => { }); }); - describe("mixed mode", () => { - it("should ignore remote configs when specified without MIXED_MODE enabled", () => { + describe("remote bindings", () => { + it("should ignore remote configs when specified without REMOTE_BINDINGS enabled", () => { const rawConfig: RawConfig = { name: "my-worker", kv_namespaces: [ { binding: "KV", id: "xxxx-xxxx-xxxx-xxxx", - remote: true, + experimental_remote: true, }, ], r2_buckets: [ { binding: "R2", bucket_name: "my-r2", - remote: 5 as unknown as boolean, + experimental_remote: 5 as unknown as boolean, }, ], }; @@ -6391,7 +6391,7 @@ describe("normalizeAndValidateConfig()", () => { { RESOURCES_PROVISION: false, MULTIWORKER: false, - MIXED_MODE: false, + REMOTE_BINDINGS: false, }, () => normalizeAndValidateConfig(rawConfig, undefined, undefined, { @@ -6401,8 +6401,8 @@ describe("normalizeAndValidateConfig()", () => { expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(` "Processing wrangler configuration: - - Unexpected fields found in kv_namespaces[0] field: \\"remote\\" - - Unexpected fields found in r2_buckets[0] field: \\"remote\\"" + - Unexpected fields found in kv_namespaces[0] field: \\"experimental_remote\\" + - Unexpected fields found in r2_buckets[0] field: \\"experimental_remote\\"" `); }); @@ -6413,14 +6413,14 @@ describe("normalizeAndValidateConfig()", () => { { binding: "KV", id: "xxxx-xxxx-xxxx-xxxx", - remote: "hello" as unknown as boolean, + experimental_remote: "hello" as unknown as boolean, }, ], r2_buckets: [ { binding: "R2", bucket_name: "my-r2", - remote: 5 as unknown as boolean, + experimental_remote: 5 as unknown as boolean, }, ], }; @@ -6428,7 +6428,7 @@ describe("normalizeAndValidateConfig()", () => { { RESOURCES_PROVISION: false, MULTIWORKER: false, - MIXED_MODE: true, + REMOTE_BINDINGS: true, }, () => normalizeAndValidateConfig(rawConfig, undefined, undefined, { @@ -6438,8 +6438,8 @@ describe("normalizeAndValidateConfig()", () => { expect(diagnostics.renderErrors()).toMatchInlineSnapshot(` "Processing wrangler configuration: - - \\"kv_namespaces[0]\\" should, optionally, have a boolean \\"remote\\" field but got {\\"binding\\":\\"KV\\",\\"id\\":\\"xxxx-xxxx-xxxx-xxxx\\",\\"remote\\":\\"hello\\"}. - - \\"r2_buckets[0]\\" should, optionally, have a boolean \\"remote\\" field but got {\\"binding\\":\\"R2\\",\\"bucket_name\\":\\"my-r2\\",\\"remote\\":5}." + - \\"kv_namespaces[0]\\" should, optionally, have a boolean \\"experimental_remote\\" field but got {\\"binding\\":\\"KV\\",\\"id\\":\\"xxxx-xxxx-xxxx-xxxx\\",\\"experimental_remote\\":\\"hello\\"}. + - \\"r2_buckets[0]\\" should, optionally, have a boolean \\"experimental_remote\\" field but got {\\"binding\\":\\"R2\\",\\"bucket_name\\":\\"my-r2\\",\\"experimental_remote\\":5}." `); }); }); diff --git a/packages/wrangler/src/__tests__/dev.test.ts b/packages/wrangler/src/__tests__/dev.test.ts index d84aea3f5c47..deb17153348d 100644 --- a/packages/wrangler/src/__tests__/dev.test.ts +++ b/packages/wrangler/src/__tests__/dev.test.ts @@ -1676,21 +1676,23 @@ describe.sequential("wrangler dev", () => { ); }); - describe("mixed mode", () => { + describe("remote bindings", () => { const wranglerConfigWithRemoteBindings = { - services: [{ binding: "WorkerA", service: "A", remote: true }], + services: [ + { binding: "WorkerA", service: "A", experimental_remote: true }, + ], kv_namespaces: [ { binding: "KV", id: "xxxx-xxxx-xxxx-xxxx", - remote: true, + experimental_remote: true, }, ], r2_buckets: [ { binding: "MY_R2", bucket_name: "my-bucket", - remote: true, + experimental_remote: true, }, ], queues: { @@ -1698,7 +1700,7 @@ describe.sequential("wrangler dev", () => { { binding: "MY_QUEUE_PRODUCES", queue: "my-queue", - remote: true, + experimental_remote: true, }, ], }, @@ -1706,7 +1708,7 @@ describe.sequential("wrangler dev", () => { { binding: "MY_D1", database_id: "xxx", - remote: true, + experimental_remote: true, }, ], workflows: [ @@ -1714,12 +1716,12 @@ describe.sequential("wrangler dev", () => { binding: "MY_WORKFLOW", name: "workflow-name", class_name: "myClass", - remote: true, + experimental_remote: true, }, ], }; - it("should ignore remote true settings without the --x-mixed-mode flag (initial logs only test)", async () => { + 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"); @@ -1738,19 +1740,19 @@ describe.sequential("wrangler dev", () => { expect(std.warn).toMatchInlineSnapshot(` "▲ [WARNING] Processing wrangler.toml configuration: - - Unexpected fields found in kv_namespaces[0] field: \\"remote\\" - - Unexpected fields found in queues.producers[0] field: \\"remote\\" - - Unexpected fields found in r2_buckets[0] field: \\"remote\\" - - Unexpected fields found in d1_databases[0] field: \\"remote\\" + - Unexpected fields found in kv_namespaces[0] field: \\"experimental_remote\\" + - Unexpected fields found in queues.producers[0] field: \\"experimental_remote\\" + - Unexpected fields found in r2_buckets[0] field: \\"experimental_remote\\" + - Unexpected fields found in d1_databases[0] field: \\"experimental_remote\\" " `); }); - it("should honor the remote true settings with the --x-mixed-mode flag (initial logs only test)", async () => { + 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-mixed-mode index.js"); + await runWranglerUntilConfig("dev --x-remote-bindings index.js"); expect(std.out).toMatchInlineSnapshot(` "Your Worker has access to the following bindings: Binding Resource Mode diff --git a/packages/wrangler/src/api/dev.ts b/packages/wrangler/src/api/dev.ts index 8dd05beedd30..0059fdb79b2d 100644 --- a/packages/wrangler/src/api/dev.ts +++ b/packages/wrangler/src/api/dev.ts @@ -221,7 +221,7 @@ export async function unstable_dev( logLevel: options?.logLevel ?? defaultLogLevel, port: options?.port ?? 0, experimentalProvision: undefined, - experimentalMixedMode: false, + experimentalRemoteBindings: false, experimentalVectorizeBindToProd: vectorizeBindToProd ?? false, experimentalImagesLocalMode: imagesLocalMode ?? false, enableIpc: options?.experimental?.enableIpc, @@ -237,7 +237,7 @@ export async function unstable_dev( // TODO: can we make this work? MULTIWORKER: false, RESOURCES_PROVISION: false, - MIXED_MODE: false, + REMOTE_BINDINGS: false, }, () => startDev(devOptions) ); diff --git a/packages/wrangler/src/api/index.ts b/packages/wrangler/src/api/index.ts index 2624b156eca4..232bccb57fba 100644 --- a/packages/wrangler/src/api/index.ts +++ b/packages/wrangler/src/api/index.ts @@ -12,4 +12,4 @@ export { } from "./mtls-certificate"; export * from "./startDevWorker"; export * from "./integrations"; -export * from "./mixedMode"; +export * from "./remoteBindings"; diff --git a/packages/wrangler/src/api/integrations/platform/index.ts b/packages/wrangler/src/api/integrations/platform/index.ts index 03f6490b3c9f..32086fa7add9 100644 --- a/packages/wrangler/src/api/integrations/platform/index.ts +++ b/packages/wrangler/src/api/integrations/platform/index.ts @@ -23,8 +23,8 @@ import type { Config, RawConfig, RawEnvironment } from "../../../config"; import type { IncomingRequestCfProperties } from "@cloudflare/workers-types/experimental"; import type { MiniflareOptions, - MixedModeConnectionString, ModuleRule, + RemoteProxyConnectionString, WorkerOptions, } from "miniflare"; @@ -114,8 +114,8 @@ export async function getPlatformProxy< { MULTIWORKER: false, RESOURCES_PROVISION: false, - // TODO: when possible mixed mode should be made available for getPlatformProxy - MIXED_MODE: false, + // TODO: when possible remote bindings should be made available for getPlatformProxy + REMOTE_BINDINGS: false, }, () => getMiniflareOptionsFromConfig(rawConfig, env, options) ); @@ -259,8 +259,8 @@ export function unstable_getMiniflareWorkerOptions( env?: string, options?: { imagesLocalMode?: boolean; - mixedModeConnectionString?: MixedModeConnectionString; - mixedModeEnabled?: boolean; + remoteProxyConnectionString?: RemoteProxyConnectionString; + remoteBindingsEnabled?: boolean; overrides?: { assets?: Partial; }; @@ -271,8 +271,8 @@ export function unstable_getMiniflareWorkerOptions( env?: string, options?: { imagesLocalMode?: boolean; - mixedModeConnectionString?: MixedModeConnectionString; - mixedModeEnabled?: boolean; + remoteProxyConnectionString?: RemoteProxyConnectionString; + remoteBindingsEnabled?: boolean; overrides?: { assets?: Partial; }; @@ -283,8 +283,8 @@ export function unstable_getMiniflareWorkerOptions( env?: string, options?: { imagesLocalMode?: boolean; - mixedModeConnectionString?: MixedModeConnectionString; - mixedModeEnabled?: boolean; + remoteProxyConnectionString?: RemoteProxyConnectionString; + remoteBindingsEnabled?: boolean; overrides?: { assets?: Partial; }; @@ -318,8 +318,8 @@ export function unstable_getMiniflareWorkerOptions( tails: config.tail_consumers, containers: {}, }, - options?.mixedModeConnectionString, - options?.mixedModeEnabled ?? false + options?.remoteProxyConnectionString, + options?.remoteBindingsEnabled ?? false ); // This function is currently only exported for the Workers Vitest pool. @@ -333,13 +333,16 @@ export function unstable_getMiniflareWorkerOptions( bindings.services.map((binding) => { const name = binding.service === config.name ? kCurrentWorker : binding.service; - if (options?.mixedModeConnectionString && binding.remote) { + if ( + options?.remoteProxyConnectionString && + binding.experimental_remote + ) { return [ binding.binding, { name, entrypoint: binding.entrypoint, - mixedModeConnectionString: options.mixedModeConnectionString, + remoteProxyConnectionString: options.remoteProxyConnectionString, }, ]; } diff --git a/packages/wrangler/src/api/mixedMode/index.ts b/packages/wrangler/src/api/remoteBindings/index.ts similarity index 66% rename from packages/wrangler/src/api/mixedMode/index.ts rename to packages/wrangler/src/api/remoteBindings/index.ts index cff6a0fa4fb1..564ff1c4472a 100644 --- a/packages/wrangler/src/api/mixedMode/index.ts +++ b/packages/wrangler/src/api/remoteBindings/index.ts @@ -13,27 +13,27 @@ import type { StartDevWorkerInput, Worker, } from "../startDevWorker/types"; -import type { MixedModeConnectionString } from "miniflare"; +import type { RemoteProxyConnectionString } from "miniflare"; -export type MixedModeSession = Pick & { +export type RemoteProxySession = Pick & { updateBindings: (bindings: StartDevWorkerInput["bindings"]) => Promise; - mixedModeConnectionString: MixedModeConnectionString; + remoteProxyConnectionString: RemoteProxyConnectionString; }; -export type StartMixedModeSessionOptions = { +export type StartRemoteProxySessionOptions = { workerName?: string; auth?: NonNullable["auth"]; /** If running in a non-public compliance region, set this here. */ complianceRegion?: Config["compliance_region"]; }; -export async function startMixedModeSession( +export async function startRemoteProxySession( bindings: StartDevWorkerInput["bindings"], - options?: StartMixedModeSessionOptions -): Promise { + options?: StartRemoteProxySessionOptions +): Promise { const proxyServerWorkerWranglerConfig = path.resolve( getBasePath(), - "templates/mixedMode/proxyServerWorker/wrangler.jsonc" + "templates/remoteBindings/proxyServerWorker/wrangler.jsonc" ); // Transform all bindings to use "raw" mode @@ -59,8 +59,8 @@ export async function startMixedModeSession( bindings: rawBindings, }); - const mixedModeConnectionString = - (await worker.url) as MixedModeConnectionString; + const remoteProxyConnectionString = + (await worker.url) as RemoteProxyConnectionString; const updateBindings = async ( newBindings: StartDevWorkerInput["bindings"] @@ -77,7 +77,7 @@ export async function startMixedModeSession( return { ready: worker.ready, - mixedModeConnectionString, + remoteProxyConnectionString, updateBindings, dispose: worker.dispose, }; @@ -93,36 +93,36 @@ export function pickRemoteBindings( return true; } - return "remote" in binding && binding["remote"]; + return "experimental_remote" in binding && binding["experimental_remote"]; }) ); } /** - * Utility for potentially starting or updating a mixed mode session. + * Utility for potentially starting or updating a remote proxy session. * - * It uses an internal map for storing existing mixed mode session indexed by worker names. If no worker name is provided - * the mixed mode session won't be retrieved nor saved to/from the internal map. + * It uses an internal map for storing existing remote proxy session indexed by worker names. If no worker name is provided + * the remote proxy session won't be retrieved nor saved to/from the internal map. * * @param configPathOrWorkerConfig either a file path to a wrangler configuration file or an object containing the name of * the target worker alongside its bindings. - * @param preExistingMixedModeSessionData the data of a pre-existing mixed mode session if there was one null otherwise - * @returns null if no existing mixed mode session was provided and one should not be created (because the worker is not - * defining any remote bindings), the data associated to the created/updated mixed mode session otherwise. + * @param preExistingRemoteProxySessionData the data of a pre-existing remote proxy session if there was one null otherwise + * @returns null if no existing remote proxy session was provided and one should not be created (because the worker is not + * defining any remote bindings), the data associated to the created/updated remote proxy session otherwise. */ -export async function maybeStartOrUpdateMixedModeSession( +export async function maybeStartOrUpdateRemoteProxySession( configPathOrWorkerConfig: | string | { name?: string; bindings: NonNullable; }, - preExistingMixedModeSessionData: { - session: MixedModeSession; + preExistingRemoteProxySessionData: { + session: RemoteProxySession; remoteBindings: Record; } | null ): Promise<{ - session: MixedModeSession; + session: RemoteProxySession; remoteBindings: Record; } | null> { if (typeof configPathOrWorkerConfig === "string") { @@ -140,33 +140,33 @@ export async function maybeStartOrUpdateMixedModeSession( const remoteBindings = pickRemoteBindings(workerConfigs.bindings); - let mixedModeSession = preExistingMixedModeSessionData?.session; + let remoteProxySession = preExistingRemoteProxySessionData?.session; const remoteBindingsAreSameAsBefore = deepStrictEqual( remoteBindings, - preExistingMixedModeSessionData?.remoteBindings + preExistingRemoteProxySessionData?.remoteBindings ); - // We only want to perform updates on the mixed mode session if the session's remote bindings have changed + // We only want to perform updates on the remote proxy session if the session's remote bindings have changed if (!remoteBindingsAreSameAsBefore) { - if (!mixedModeSession) { + if (!remoteProxySession) { if (Object.keys(remoteBindings).length > 0) { - mixedModeSession = await startMixedModeSession(remoteBindings); + remoteProxySession = await startRemoteProxySession(remoteBindings); } } else { // Note: we always call updateBindings even when there are zero remote bindings, in these // cases we could terminate the remote session if we wanted, that's probably // something to consider down the line - await mixedModeSession.updateBindings(remoteBindings); + await remoteProxySession.updateBindings(remoteBindings); } } - await mixedModeSession?.ready; - if (!mixedModeSession) { + await remoteProxySession?.ready; + if (!remoteProxySession) { return null; } return { - session: mixedModeSession, + session: remoteProxySession, remoteBindings, }; } diff --git a/packages/wrangler/src/api/startDevWorker/ConfigController.ts b/packages/wrangler/src/api/startDevWorker/ConfigController.ts index f98d24a8e398..2ca539329e87 100644 --- a/packages/wrangler/src/api/startDevWorker/ConfigController.ts +++ b/packages/wrangler/src/api/startDevWorker/ConfigController.ts @@ -153,8 +153,8 @@ async function resolveDevConfig( bindVectorizeToProd: input.dev?.bindVectorizeToProd ?? false, multiworkerPrimary: input.dev?.multiworkerPrimary, imagesLocalMode: input.dev?.imagesLocalMode ?? false, - experimentalMixedMode: - input.dev?.experimentalMixedMode ?? getFlag("MIXED_MODE"), + experimentalRemoteBindings: + input.dev?.experimentalRemoteBindings ?? getFlag("REMOTE_BINDINGS"), enableContainers: input.dev?.enableContainers ?? config.dev.enable_containers, dockerPath: input.dev?.dockerPath ?? getDockerPath(), @@ -191,7 +191,7 @@ async function resolveBindings( input.bindings )?.[0], }, - input.dev?.experimentalMixedMode + input.dev?.experimentalRemoteBindings ); const maskedVars = maskVars(bindings, config); @@ -359,7 +359,7 @@ async function resolveConfig( if ( extractBindingsOfType("browser", resolved.bindings).length && !resolved.dev.remote && - !getFlag("MIXED_MODE") + !getFlag("REMOTE_BINDINGS") ) { logger.warn( "Browser Rendering is not supported locally. Please use `wrangler dev --remote` instead." diff --git a/packages/wrangler/src/api/startDevWorker/LocalRuntimeController.ts b/packages/wrangler/src/api/startDevWorker/LocalRuntimeController.ts index bd3cc4fa87a9..5fd0b5a91cf9 100644 --- a/packages/wrangler/src/api/startDevWorker/LocalRuntimeController.ts +++ b/packages/wrangler/src/api/startDevWorker/LocalRuntimeController.ts @@ -11,7 +11,7 @@ import { convertCfWorkerInitBindingsToBindings, } from "./utils"; import type { WorkerEntrypointsDefinition } from "../../dev-registry"; -import type { MixedModeSession } from "../mixedMode"; +import type { RemoteProxySession } from "../remoteBindings"; import type { BundleCompleteEvent, BundleStartEvent, @@ -159,8 +159,8 @@ export class LocalRuntimeController extends RuntimeController { #mutex = new Mutex(); #mf?: Miniflare; - #mixedModeSessionData: { - session: MixedModeSession; + #remoteProxySessionData: { + session: RemoteProxySession; remoteBindings: Record; } | null = null; @@ -172,25 +172,26 @@ export class LocalRuntimeController extends RuntimeController { try { const configBundle = await convertToConfigBundle(data); - const experimentalMixedMode = - data.config.dev.experimentalMixedMode ?? false; + const experimentalRemoteBindings = + data.config.dev.experimentalRemoteBindings ?? false; - if (experimentalMixedMode && !data.config.dev?.remote) { + if (experimentalRemoteBindings && !data.config.dev?.remote) { // note: mixedMode uses (transitively) LocalRuntimeController, so we need to import // from the module lazily in order to avoid circular dependency issues - const { maybeStartOrUpdateMixedModeSession } = await import( - "../mixedMode" + const { maybeStartOrUpdateRemoteProxySession } = await import( + "../remoteBindings" ); - this.#mixedModeSessionData = await maybeStartOrUpdateMixedModeSession( - { - name: configBundle.name, - bindings: - convertCfWorkerInitBindingsToBindings(configBundle.bindings) ?? - {}, - }, - this.#mixedModeSessionData ?? null - ); + this.#remoteProxySessionData = + await maybeStartOrUpdateRemoteProxySession( + { + name: configBundle.name, + bindings: + convertCfWorkerInitBindingsToBindings(configBundle.bindings) ?? + {}, + }, + this.#remoteProxySessionData ?? null + ); } const { options, internalObjects, entrypointNames } = @@ -198,8 +199,8 @@ export class LocalRuntimeController extends RuntimeController { this.#log, configBundle, this.#proxyToUserWorkerAuthenticationSecret, - this.#mixedModeSessionData?.session?.mixedModeConnectionString, - !!experimentalMixedMode + this.#remoteProxySessionData?.session?.remoteProxyConnectionString, + !!experimentalRemoteBindings ); options.liveReload = false; // TODO: set in buildMiniflareOptions once old code path is removed if (this.#mf === undefined) { @@ -310,12 +311,12 @@ export class LocalRuntimeController extends RuntimeController { await this.#mf?.dispose(); this.#mf = undefined; - if (this.#mixedModeSessionData) { + if (this.#remoteProxySessionData) { logger.log(chalk.dim("⎔ Shutting down remote connection...")); } - await this.#mixedModeSessionData?.session?.dispose(); - this.#mixedModeSessionData = null; + await this.#remoteProxySessionData?.session?.dispose(); + this.#remoteProxySessionData = null; logger.debug("LocalRuntimeController teardown complete"); }; diff --git a/packages/wrangler/src/api/startDevWorker/MultiworkerRuntimeController.ts b/packages/wrangler/src/api/startDevWorker/MultiworkerRuntimeController.ts index 2a6fa749bc24..5320df1c2d79 100644 --- a/packages/wrangler/src/api/startDevWorker/MultiworkerRuntimeController.ts +++ b/packages/wrangler/src/api/startDevWorker/MultiworkerRuntimeController.ts @@ -10,7 +10,7 @@ import { LocalRuntimeController, } from "./LocalRuntimeController"; import { convertCfWorkerInitBindingsToBindings } from "./utils"; -import type { MixedModeSession } from "../mixedMode"; +import type { RemoteProxySession } from "../remoteBindings"; import type { BundleCompleteEvent } from "./events"; import type { Binding } from "./index"; @@ -65,10 +65,10 @@ export class MultiworkerRuntimeController extends LocalRuntimeController { #options = new Map(); - #mixedModeSessionsData = new Map< + #remoteProxySessionsData = new Map< string, { - session: MixedModeSession; + session: RemoteProxySession; remoteBindings: Record; } | null >(); @@ -105,26 +105,27 @@ export class MultiworkerRuntimeController extends LocalRuntimeController { try { const configBundle = await convertToConfigBundle(data); - const experimentalMixedMode = data.config.dev.experimentalMixedMode; + const experimentalRemoteBindings = + data.config.dev.experimentalRemoteBindings; - if (experimentalMixedMode && !data.config.dev?.remote) { + if (experimentalRemoteBindings && !data.config.dev?.remote) { // note: mixedMode uses (transitively) LocalRuntimeController, so we need to import // from the module lazily in order to avoid circular dependency issues - const { maybeStartOrUpdateMixedModeSession } = await import( - "../mixedMode" + const { maybeStartOrUpdateRemoteProxySession } = await import( + "../remoteBindings" ); - const mixedModeSession = await maybeStartOrUpdateMixedModeSession( + const remoteProxySession = await maybeStartOrUpdateRemoteProxySession( { name: configBundle.name, bindings: convertCfWorkerInitBindingsToBindings(configBundle.bindings) ?? {}, }, - this.#mixedModeSessionsData.get(data.config.name) ?? null + this.#remoteProxySessionsData.get(data.config.name) ?? null ); - this.#mixedModeSessionsData.set( + this.#remoteProxySessionsData.set( data.config.name, - mixedModeSession ?? null + remoteProxySession ?? null ); } @@ -132,9 +133,9 @@ export class MultiworkerRuntimeController extends LocalRuntimeController { this.#log, await convertToConfigBundle(data), this.#proxyToUserWorkerAuthenticationSecret, - this.#mixedModeSessionsData.get(data.config.name)?.session - ?.mixedModeConnectionString, - !!experimentalMixedMode + this.#remoteProxySessionsData.get(data.config.name)?.session + ?.remoteProxyConnectionString, + !!experimentalRemoteBindings ); this.#options.set(data.config.name, { @@ -247,17 +248,17 @@ export class MultiworkerRuntimeController extends LocalRuntimeController { await this.#mf?.dispose(); this.#mf = undefined; - if (this.#mixedModeSessionsData.size > 0) { + if (this.#remoteProxySessionsData.size > 0) { logger.log(chalk.dim("⎔ Shutting down remote connections...")); } await Promise.all( - [...this.#mixedModeSessionsData.values()].map((mixedModeSessionData) => - mixedModeSessionData?.session?.dispose() + [...this.#remoteProxySessionsData.values()].map( + (remoteProxySessionData) => remoteProxySessionData?.session?.dispose() ) ); - this.#mixedModeSessionsData.clear(); + this.#remoteProxySessionsData.clear(); logger.debug("MultiworkerRuntimeController teardown complete"); }; diff --git a/packages/wrangler/src/api/startDevWorker/types.ts b/packages/wrangler/src/api/startDevWorker/types.ts index 8836a7bc2626..c35613e9616d 100644 --- a/packages/wrangler/src/api/startDevWorker/types.ts +++ b/packages/wrangler/src/api/startDevWorker/types.ts @@ -154,7 +154,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 remote: true (remote mode) and remote: false (local mode). */ + /** The local address to reach your worker. Applies to experimental_remote: true (remote mode) and remote: false (local mode). */ server?: { hostname?: string; // --ip port?: number; // --port @@ -183,8 +183,8 @@ export interface StartDevWorkerInput { /** Treat this as the primary worker in a multiworker setup (i.e. the first Worker in Miniflare's options) */ multiworkerPrimary?: boolean; - /** Whether the experimental mixed mode feature should be enabled */ - experimentalMixedMode?: boolean; + /** Whether the experimental remote bindings feature should be enabled */ + experimentalRemoteBindings?: boolean; /** Whether to build and connect to containers during local dev. Requires Docker daemon to be running. Defaults to true. */ enableContainers?: boolean; diff --git a/packages/wrangler/src/cli.ts b/packages/wrangler/src/cli.ts index 739990e2a54b..1f0cb64a74be 100644 --- a/packages/wrangler/src/cli.ts +++ b/packages/wrangler/src/cli.ts @@ -65,11 +65,11 @@ export { export { experimental_patchConfig } from "./config/patch-config"; export { - startMixedModeSession as experimental_startMixedModeSession, - type StartMixedModeSessionOptions as experimental_StartMixedModeSessionOptions, - maybeStartOrUpdateMixedModeSession as experimental_maybeStartOrUpdateMixedModeSession, + startRemoteProxySession as experimental_startRemoteProxySession, + type StartRemoteProxySessionOptions as experimental_StartRemoteProxySessionOptions, + maybeStartOrUpdateRemoteProxySession as experimental_maybeStartOrUpdateRemoteProxySession, pickRemoteBindings as experimental_pickRemoteBindings, type Binding as Unstable_Binding, - type MixedModeSession as Experimental_MixedModeSession, + type RemoteProxySession as Experimental_RemoteProxySession, convertConfigBindingsToStartWorkerBindings as unstable_convertConfigBindingsToStartWorkerBindings, } from "./api"; diff --git a/packages/wrangler/src/config/environment.ts b/packages/wrangler/src/config/environment.ts index 82d3d2c1261c..e2618e1a96a1 100644 --- a/packages/wrangler/src/config/environment.ts +++ b/packages/wrangler/src/config/environment.ts @@ -463,8 +463,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-mixed-mode`) */ - remote?: boolean; + /** Whether the Workflow should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; }; /** @@ -571,8 +571,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-mixed-mode`) */ - remote?: boolean; + /** Whether the KV namespace should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; }[]; /** @@ -618,8 +618,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-mixed-mode`) */ - remote?: boolean; + /** Whether the Queue producer should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; }[]; /** Consumer configuration */ @@ -673,8 +673,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-mixed-mode`) */ - remote?: boolean; + /** Whether the R2 bucket should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; }[]; /** @@ -703,8 +703,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-mixed-mode`) */ - remote?: boolean; + /** Whether the D1 database should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; }[]; /** @@ -723,8 +723,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-mixed-mode`) */ - remote?: boolean; + /** Whether the Vectorize index should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; }[]; /** @@ -770,8 +770,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-mixed-mode`) */ - remote?: boolean; + /** Whether the service binding should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; }[] | undefined; @@ -807,8 +807,8 @@ export interface EnvironmentNonInheritable { browser: | { binding: string; - /** Whether the Browser binding should be remote or not (only available under `--x-mixed-mode`) */ - remote?: boolean; + /** Whether the Browser binding should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; } | undefined; @@ -827,8 +827,8 @@ export interface EnvironmentNonInheritable { | { binding: string; staging?: boolean; - /** Whether the AI binding should be remote or not (only available under `--x-mixed-mode`) */ - remote?: boolean; + /** Whether the AI binding should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; } | undefined; @@ -846,8 +846,8 @@ export interface EnvironmentNonInheritable { images: | { binding: string; - /** Whether the Images binding should be remote or not (only available under `--x-mixed-mode`) */ - remote?: boolean; + /** Whether the Images binding should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; } | undefined; @@ -921,8 +921,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-mixed-mode`) */ - remote?: boolean; + /** Whether the mtls fetcher should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; }[]; /** @@ -954,8 +954,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-mixed-mode`) */ - remote?: boolean; + /** Whether the Dispatch Namespace should be remote or not (only available under `--x-remote-bindings`) */ + experimental_remote?: boolean; }[]; /** diff --git a/packages/wrangler/src/config/index.ts b/packages/wrangler/src/config/index.ts index 31fe92377334..38041d9e2147 100644 --- a/packages/wrangler/src/config/index.ts +++ b/packages/wrangler/src/config/index.ts @@ -73,7 +73,7 @@ export type ReadConfigCommandArgs = NormalizeAndValidateConfigArgs & { export type ReadConfigOptions = ResolveConfigPathOptions & { hideWarnings?: boolean; experimental?: { - mixedModeEnabled?: boolean; + remoteBindingsEnabled?: boolean; }; }; @@ -105,15 +105,15 @@ export function readConfig( options ); - // TODO: here we're overriding the MIXED_MODE flag based on options.experimental?.mixedModeEnabled, - // once the MIXED_MODE flag is removed we should just normally call normalizeAndValidateConfig + // TODO: here we're overriding the REMOTE_BINDINGS flag based on options.experimental?.remoteBindingsEnabled, + // once the REMOTE_BINDINGS flag is removed we should just normally call normalizeAndValidateConfig const { diagnostics, config } = run( { RESOURCES_PROVISION: getFlag("RESOURCES_PROVISION") ?? false, MULTIWORKER: getFlag("MULTIWORKER") ?? false, - MIXED_MODE: - options.experimental?.mixedModeEnabled ?? - getFlag("MIXED_MODE") ?? + REMOTE_BINDINGS: + options.experimental?.remoteBindingsEnabled ?? + getFlag("REMOTE_BINDINGS") ?? false, }, () => { diff --git a/packages/wrangler/src/config/validation.ts b/packages/wrangler/src/config/validation.ts index 82aab3f0970c..b19ab2ae91e4 100644 --- a/packages/wrangler/src/config/validation.ts +++ b/packages/wrangler/src/config/validation.ts @@ -2191,7 +2191,7 @@ const validateNamedSimpleBinding = validateAdditionalProperties(diagnostics, field, Object.keys(value), [ "binding", - ...(getFlag("MIXED_MODE") ? ["remote"] : []), + ...(getFlag("REMOTE_BINDINGS") ? ["experimental_remote"] : []), ]); return isValid; @@ -2554,7 +2554,7 @@ const validateKVBinding: ValidatorFn = (diagnostics, field, value) => { "binding", "id", "preview_id", - ...(getFlag("MIXED_MODE") ? ["remote"] : []), + ...(getFlag("REMOTE_BINDINGS") ? ["experimental_remote"] : []), ]); return isValid; @@ -2628,7 +2628,7 @@ const validateQueueBinding: ValidatorFn = (diagnostics, field, value) => { "binding", "queue", "delivery_delay", - ...(getFlag("MIXED_MODE") ? ["remote"] : []), + ...(getFlag("REMOTE_BINDINGS") ? ["experimental_remote"] : []), ]) ) { return false; @@ -2760,7 +2760,7 @@ const validateR2Binding: ValidatorFn = (diagnostics, field, value) => { "bucket_name", "preview_bucket_name", "jurisdiction", - ...(getFlag("MIXED_MODE") ? ["remote"] : []), + ...(getFlag("REMOTE_BINDINGS") ? ["experimental_remote"] : []), ]); return isValid; @@ -2821,7 +2821,7 @@ const validateD1Binding: ValidatorFn = (diagnostics, field, value) => { "migrations_dir", "migrations_table", "preview_database_id", - ...(getFlag("MIXED_MODE") ? ["remote"] : []), + ...(getFlag("REMOTE_BINDINGS") ? ["experimental_remote"] : []), ]); return isValid; @@ -2860,7 +2860,7 @@ const validateVectorizeBinding: ValidatorFn = (diagnostics, field, value) => { validateAdditionalProperties(diagnostics, field, Object.keys(value), [ "binding", "index_name", - ...(getFlag("MIXED_MODE") ? ["remote"] : []), + ...(getFlag("REMOTE_BINDINGS") ? ["experimental_remote"] : []), ]); return isValid; @@ -3224,7 +3224,7 @@ const validateMTlsCertificateBinding: ValidatorFn = ( validateAdditionalProperties(diagnostics, field, Object.keys(value), [ "binding", "certificate_id", - ...(getFlag("MIXED_MODE") ? ["remote"] : []), + ...(getFlag("REMOTE_BINDINGS") ? ["experimental_remote"] : []), ]); if (!isRemoteValid(value, field, diagnostics)) { @@ -3783,15 +3783,15 @@ function isRemoteValid( fieldPath: string, diagnostics: Diagnostics ) { - if (!getFlag("MIXED_MODE")) { - // the remote config only applies to mixed mode, if mixed mode - // is not enabled just return true and skip this validation + if (!getFlag("REMOTE_BINDINGS")) { + // the remote config only applies to remote bindings, if remote bindings + // are not enabled just return true and skip this validation return true; } - if (!isOptionalProperty(targetObject, "remote", "boolean")) { + if (!isOptionalProperty(targetObject, "experimental_remote", "boolean")) { diagnostics.errors.push( - `"${fieldPath}" should, optionally, have a boolean "remote" field but got ${JSON.stringify( + `"${fieldPath}" should, optionally, have a boolean "experimental_remote" field but got ${JSON.stringify( targetObject )}.` ); diff --git a/packages/wrangler/src/core/register-yargs-command.ts b/packages/wrangler/src/core/register-yargs-command.ts index 0bb7e8fc8bd0..28c9e80961ed 100644 --- a/packages/wrangler/src/core/register-yargs-command.ts +++ b/packages/wrangler/src/core/register-yargs-command.ts @@ -155,7 +155,7 @@ function createHandler(def: CommandDefinition, commandName: string) { : { MULTIWORKER: false, RESOURCES_PROVISION: args.experimentalProvision ?? false, - MIXED_MODE: args.experimentalMixedMode ?? false, + REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false, }; await run(experimentalFlags, () => { diff --git a/packages/wrangler/src/deploy/index.ts b/packages/wrangler/src/deploy/index.ts index ae38c35e877e..19a4e86aab71 100644 --- a/packages/wrangler/src/deploy/index.ts +++ b/packages/wrangler/src/deploy/index.ts @@ -220,7 +220,7 @@ export const deployCommand = createCommand({ overrideExperimentalFlags: (args) => ({ MULTIWORKER: false, RESOURCES_PROVISION: args.experimentalProvision ?? false, - MIXED_MODE: false, + REMOTE_BINDINGS: false, }), warnIfMultipleEnvsConfiguredButNoneSpecified: true, }, diff --git a/packages/wrangler/src/deployment-bundle/worker.ts b/packages/wrangler/src/deployment-bundle/worker.ts index 1be2653fc7fb..e6435efa0d25 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; - remote?: boolean; + experimental_remote?: boolean; raw?: boolean; } @@ -124,7 +124,7 @@ export interface CfTextBlobBindings { export interface CfBrowserBinding { binding: string; raw?: boolean; - remote?: boolean; + experimental_remote?: boolean; } /** @@ -134,7 +134,7 @@ export interface CfBrowserBinding { export interface CfAIBinding { binding: string; staging?: boolean; - remote?: boolean; + experimental_remote?: boolean; raw?: boolean; } @@ -144,7 +144,7 @@ export interface CfAIBinding { export interface CfImagesBinding { binding: string; raw?: boolean; - remote?: boolean; + experimental_remote?: boolean; } /** @@ -178,7 +178,7 @@ export interface CfWorkflow { class_name: string; binding: string; script_name?: string; - remote?: boolean; + experimental_remote?: boolean; raw?: boolean; } @@ -186,7 +186,7 @@ export interface CfQueue { binding: string; queue_name: string; delivery_delay?: number; - remote?: boolean; + experimental_remote?: boolean; raw?: boolean; } @@ -194,7 +194,7 @@ export interface CfR2Bucket { binding: string; bucket_name?: string | typeof INHERIT_SYMBOL; jurisdiction?: string; - remote?: boolean; + experimental_remote?: boolean; raw?: boolean; } @@ -207,7 +207,7 @@ export interface CfD1Database { database_internal_env?: string; migrations_table?: string; migrations_dir?: string; - remote?: boolean; + experimental_remote?: boolean; raw?: boolean; } @@ -215,7 +215,7 @@ export interface CfVectorize { binding: string; index_name: string; raw?: boolean; - remote?: boolean; + experimental_remote?: boolean; } export interface CfSecretsStoreSecrets { @@ -241,7 +241,7 @@ export interface CfService { environment?: string; entrypoint?: string; props?: Record; - remote?: boolean; + experimental_remote?: boolean; } export interface CfAnalyticsEngineDataset { @@ -257,13 +257,13 @@ export interface CfDispatchNamespace { environment?: string; parameters?: string[]; }; - remote?: boolean; + experimental_remote?: boolean; } export interface CfMTlsCertificate { binding: string; certificate_id: string; - remote?: boolean; + experimental_remote?: boolean; } export interface CfLogfwdr { diff --git a/packages/wrangler/src/dev.ts b/packages/wrangler/src/dev.ts index 577845233232..1cde1278d44e 100644 --- a/packages/wrangler/src/dev.ts +++ b/packages/wrangler/src/dev.ts @@ -45,8 +45,12 @@ import type { } from "./config/environment"; import type { INHERIT_SYMBOL } from "./deployment-bundle/bindings"; import type { + CfD1Database, CfKvNamespace, CfModule, + CfQueue, + CfR2Bucket, + CfService, CfWorkerInit, } from "./deployment-bundle/worker"; import type { WorkerRegistry } from "./dev-registry"; @@ -61,7 +65,7 @@ export const dev = createCommand({ overrideExperimentalFlags: (args) => ({ MULTIWORKER: Array.isArray(args.config), RESOURCES_PROVISION: args.experimentalProvision ?? false, - MIXED_MODE: args.experimentalMixedMode ?? false, + REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false, }), }, metadata: { @@ -849,7 +853,7 @@ export function getBindings( env: string | undefined, local: boolean, args: AdditionalDevProps, - mixedModeEnabled = getFlag("MIXED_MODE") + remoteBindingsEnabled = getFlag("REMOTE_BINDINGS") ): CfWorkerInit["bindings"] { /** * In Pages, KV, DO, D1, R2, AI and service bindings can be specified as @@ -859,7 +863,7 @@ export function getBindings( */ // merge KV bindings const kvConfig = (configParam.kv_namespaces || []).map( - ({ binding, preview_id, id, remote }) => { + ({ binding, preview_id, id, experimental_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` @@ -876,8 +880,8 @@ export function getBindings( return { binding, id: preview_id ?? id, - remote: mixedModeEnabled && remote, - }; + experimental_remote: remoteBindingsEnabled && experimental_remote, + } satisfies CfKvNamespace; } ); const kvArgs = args.kv || []; @@ -897,9 +901,9 @@ export function getBindings( if (local) { return { ...d1Db, - remote: mixedModeEnabled && d1Db.remote, + experimental_remote: remoteBindingsEnabled && d1Db.experimental_remote, database_id, - }; + } satisfies CfD1Database; } // if you have a preview_database_id, we'll use it, but we shouldn't force people to use it. if (!d1Db.preview_database_id && !process.env.NO_D1_WARNING) { @@ -915,7 +919,13 @@ export function getBindings( // merge R2 bindings const r2Config: EnvironmentNonInheritable["r2_buckets"] = configParam.r2_buckets?.map( - ({ binding, preview_bucket_name, bucket_name, jurisdiction, remote }) => { + ({ + binding, + preview_bucket_name, + bucket_name, + jurisdiction, + experimental_remote, + }) => { // same idea as kv namespace preview id, // same copy-on-write TODO if (!preview_bucket_name && !local) { @@ -927,8 +937,8 @@ export function getBindings( binding, bucket_name: preview_bucket_name ?? bucket_name, jurisdiction, - remote: mixedModeEnabled && remote, - }; + experimental_remote: remoteBindingsEnabled && experimental_remote, + } satisfies CfR2Bucket; } ) || []; const r2Args = args.r2 || []; @@ -941,10 +951,16 @@ export function getBindings( servicesConfig, servicesArgs, "binding" - ).map((service) => ({ - ...service, - remote: mixedModeEnabled && "remote" in service && !!service.remote, - })); + ).map( + (service) => + ({ + ...service, + experimental_remote: + remoteBindingsEnabled && + "experimental_remote" in service && + !!service.experimental_remote, + }) satisfies CfService + ); // Hyperdrive bindings const hyperdriveBindings = configParam.hyperdrive.map((hyperdrive) => { @@ -982,8 +998,8 @@ export function getBindings( binding: queue.binding, queue_name: queue.queue, delivery_delay: queue.delivery_delay, - remote: mixedModeEnabled && queue.remote, - }; + experimental_remote: remoteBindingsEnabled && queue.experimental_remote, + } satisfies CfQueue; }), ]; diff --git a/packages/wrangler/src/dev/miniflare.ts b/packages/wrangler/src/dev/miniflare.ts index 4a35f19c400a..9e1f03bbff3f 100644 --- a/packages/wrangler/src/dev/miniflare.ts +++ b/packages/wrangler/src/dev/miniflare.ts @@ -50,7 +50,7 @@ import type { EsbuildBundle } from "./use-esbuild"; import type { DOContainerOptions, MiniflareOptions, - MixedModeConnectionString, + RemoteProxyConnectionString, SourceOptions, WorkerOptions, } from "miniflare"; @@ -327,65 +327,70 @@ function getRemoteId(id: string | symbol | undefined): string | null { } function kvNamespaceEntry( - { binding, id: originalId, remote }: CfKvNamespace, - mixedModeConnectionString?: MixedModeConnectionString + { binding, id: originalId, experimental_remote }: CfKvNamespace, + remoteProxyConnectionString?: RemoteProxyConnectionString ): [ string, - { id: string; mixedModeConnectionString?: MixedModeConnectionString }, + { id: string; remoteProxyConnectionString?: RemoteProxyConnectionString }, ] { const id = getRemoteId(originalId) ?? binding; - if (!mixedModeConnectionString || !remote) { + if (!remoteProxyConnectionString || !experimental_remote) { return [binding, { id }]; } - return [binding, { id, mixedModeConnectionString }]; + return [binding, { id, remoteProxyConnectionString }]; } function r2BucketEntry( - { binding, bucket_name, remote }: CfR2Bucket, - mixedModeConnectionString?: MixedModeConnectionString + { binding, bucket_name, experimental_remote }: CfR2Bucket, + remoteProxyConnectionString?: RemoteProxyConnectionString ): [ string, - { id: string; mixedModeConnectionString?: MixedModeConnectionString }, + { id: string; remoteProxyConnectionString?: RemoteProxyConnectionString }, ] { const id = getRemoteId(bucket_name) ?? binding; - if (!mixedModeConnectionString || !remote) { + if (!remoteProxyConnectionString || !experimental_remote) { return [binding, { id }]; } - return [binding, { id, mixedModeConnectionString }]; + return [binding, { id, remoteProxyConnectionString }]; } function d1DatabaseEntry( - { binding, database_id, preview_database_id, remote }: CfD1Database, - mixedModeConnectionString?: MixedModeConnectionString + { + binding, + database_id, + preview_database_id, + experimental_remote, + }: CfD1Database, + remoteProxyConnectionString?: RemoteProxyConnectionString ): [ string, - { id: string; mixedModeConnectionString?: MixedModeConnectionString }, + { id: string; remoteProxyConnectionString?: RemoteProxyConnectionString }, ] { const id = getRemoteId(preview_database_id ?? database_id) ?? binding; - if (!mixedModeConnectionString || !remote) { + if (!remoteProxyConnectionString || !experimental_remote) { return [binding, { id }]; } - return [binding, { id, mixedModeConnectionString }]; + return [binding, { id, remoteProxyConnectionString }]; } function queueProducerEntry( { binding, queue_name: queueName, delivery_delay: deliveryDelay, - remote, + experimental_remote, }: CfQueue, - mixedModeConnectionString?: MixedModeConnectionString + remoteProxyConnectionString?: RemoteProxyConnectionString ): [ string, { queueName: string; deliveryDelay: number | undefined; - mixedModeConnectionString?: MixedModeConnectionString; + remoteProxyConnectionString?: RemoteProxyConnectionString; }, ] { - if (!mixedModeConnectionString || !remote) { + if (!remoteProxyConnectionString || !experimental_remote) { return [binding, { queueName, deliveryDelay }]; } - return [binding, { queueName, deliveryDelay, mixedModeConnectionString }]; + return [binding, { queueName, deliveryDelay, remoteProxyConnectionString }]; } function pipelineEntry(pipeline: CfPipeline): [string, string] { return [pipeline.binding, pipeline.pipeline]; @@ -399,19 +404,19 @@ function workflowEntry( name, class_name: className, script_name: scriptName, - remote, + experimental_remote, }: CfWorkflow, - mixedModeConnectionString?: MixedModeConnectionString + remoteProxyConnectionString?: RemoteProxyConnectionString ): [ string, { name: string; className: string; scriptName?: string; - mixedModeConnectionString?: MixedModeConnectionString; + remoteProxyConnectionString?: RemoteProxyConnectionString; }, ] { - if (!mixedModeConnectionString || !remote) { + if (!remoteProxyConnectionString || !experimental_remote) { return [ binding, { @@ -428,33 +433,39 @@ function workflowEntry( name, className, scriptName, - mixedModeConnectionString, + remoteProxyConnectionString, }, ]; } function dispatchNamespaceEntry({ binding, namespace, - remote, + experimental_remote, }: CfDispatchNamespace): [string, { namespace: string }]; function dispatchNamespaceEntry( - { binding, namespace, remote }: CfDispatchNamespace, - mixedModeConnectionString: MixedModeConnectionString + { binding, namespace, experimental_remote }: CfDispatchNamespace, + remoteProxyConnectionString: RemoteProxyConnectionString ): [ string, - { namespace: string; mixedModeConnectionString: MixedModeConnectionString }, + { + namespace: string; + remoteProxyConnectionString: RemoteProxyConnectionString; + }, ]; function dispatchNamespaceEntry( - { binding, namespace, remote }: CfDispatchNamespace, - mixedModeConnectionString?: MixedModeConnectionString + { binding, namespace, experimental_remote }: CfDispatchNamespace, + remoteProxyConnectionString?: RemoteProxyConnectionString ): [ string, - { namespace: string; mixedModeConnectionString?: MixedModeConnectionString }, + { + namespace: string; + remoteProxyConnectionString?: RemoteProxyConnectionString; + }, ] { - if (!mixedModeConnectionString || !remote) { + if (!remoteProxyConnectionString || !experimental_remote) { return [binding, { namespace }]; } - return [binding, { namespace, mixedModeConnectionString }]; + return [binding, { namespace, remoteProxyConnectionString }]; } // eslint-disable-next-line @typescript-eslint/no-explicit-any function ratelimitEntry(ratelimit: CfUnsafeBinding): [string, any] { @@ -523,8 +534,8 @@ type MiniflareBindingsConfig = Pick< // each plugin options schema and use those export function buildMiniflareBindingOptions( config: MiniflareBindingsConfig, - mixedModeConnectionString: MixedModeConnectionString | undefined, - mixedModeEnabled: boolean + remoteProxyConnectionString: RemoteProxyConnectionString | undefined, + remoteBindingsEnabled: boolean ): { bindingOptions: WorkerOptionsBindings; internalObjects: CfDurableObject[]; @@ -559,12 +570,12 @@ export function buildMiniflareBindingOptions( const notFoundServices = new Set(); for (const service of config.services ?? []) { - if (mixedModeConnectionString && service.remote) { + if (remoteProxyConnectionString && service.experimental_remote) { serviceBindings[service.binding] = { name: service.service, props: service.props, entrypoint: service.entrypoint, - mixedModeConnectionString, + remoteProxyConnectionString, }; continue; } @@ -789,7 +800,7 @@ export function buildMiniflareBindingOptions( } const wrappedBindings: WorkerOptions["wrappedBindings"] = {}; - if (bindings.ai?.binding && !mixedModeEnabled) { + if (bindings.ai?.binding && !remoteBindingsEnabled) { externalWorkers.push({ name: `${EXTERNAL_AI_WORKER_NAME}:${config.name}`, modules: [ @@ -811,17 +822,17 @@ export function buildMiniflareBindingOptions( }; } - if (bindings.ai && mixedModeEnabled) { - warnOrError("ai", bindings.ai.remote, "always-remote"); + if (bindings.ai && remoteBindingsEnabled) { + warnOrError("ai", bindings.ai.experimental_remote, "always-remote"); } - if (bindings.browser && mixedModeEnabled) { - warnOrError("browser", bindings.browser.remote, "remote"); + if (bindings.browser && remoteBindingsEnabled) { + warnOrError("browser", bindings.browser.experimental_remote, "remote"); } - if (bindings.mtls_certificates && mixedModeEnabled) { + if (bindings.mtls_certificates && remoteBindingsEnabled) { for (const mtls of bindings.mtls_certificates) { - warnOrError("ai", mtls.remote, "always-remote"); + warnOrError("ai", mtls.experimental_remote, "always-remote"); } } @@ -829,7 +840,7 @@ export function buildMiniflareBindingOptions( if ( bindings.images?.binding && !config.imagesLocalMode && - !mixedModeEnabled + !remoteBindingsEnabled ) { externalWorkers.push({ name: `${EXTERNAL_IMAGES_WORKER_NAME}:${config.name}`, @@ -852,7 +863,7 @@ export function buildMiniflareBindingOptions( }; } - if (bindings.vectorize && !mixedModeEnabled) { + if (bindings.vectorize && !remoteBindingsEnabled) { for (const vectorizeBinding of bindings.vectorize) { const bindingName = vectorizeBinding.binding; const indexName = vectorizeBinding.index_name; @@ -898,31 +909,31 @@ export function buildMiniflareBindingOptions( wasmBindings, ai: - bindings.ai && mixedModeConnectionString + bindings.ai && remoteProxyConnectionString ? { binding: bindings.ai.binding, - mixedModeConnectionString, + remoteProxyConnectionString, } : undefined, kvNamespaces: Object.fromEntries( bindings.kv_namespaces?.map((kv) => - kvNamespaceEntry(kv, mixedModeConnectionString) + kvNamespaceEntry(kv, remoteProxyConnectionString) ) ?? [] ), r2Buckets: Object.fromEntries( bindings.r2_buckets?.map((r2) => - r2BucketEntry(r2, mixedModeConnectionString) + r2BucketEntry(r2, remoteProxyConnectionString) ) ?? [] ), d1Databases: Object.fromEntries( bindings.d1_databases?.map((d1) => - d1DatabaseEntry(d1, mixedModeConnectionString) + d1DatabaseEntry(d1, remoteProxyConnectionString) ) ?? [] ), queueProducers: Object.fromEntries( bindings.queues?.map((queue) => - queueProducerEntry(queue, mixedModeConnectionString) + queueProducerEntry(queue, remoteProxyConnectionString) ) ?? [] ), queueConsumers: Object.fromEntries( @@ -940,7 +951,7 @@ export function buildMiniflareBindingOptions( ), workflows: Object.fromEntries( bindings.workflows?.map((workflow) => - workflowEntry(workflow, mixedModeConnectionString) + workflowEntry(workflow, remoteProxyConnectionString) ) ?? [] ), secretsStoreSecrets: Object.fromEntries( @@ -959,37 +970,39 @@ export function buildMiniflareBindingOptions( send_email: bindings.send_email, }, images: - bindings.images && (config.imagesLocalMode || mixedModeEnabled) + bindings.images && (config.imagesLocalMode || remoteBindingsEnabled) ? { binding: bindings.images.binding, - mixedModeConnectionString: - bindings.images.remote && mixedModeConnectionString - ? mixedModeConnectionString + remoteProxyConnectionString: + bindings.images.experimental_remote && remoteProxyConnectionString + ? remoteProxyConnectionString : undefined, } : undefined, browserRendering: - mixedModeEnabled && mixedModeConnectionString && bindings.browser?.remote + remoteBindingsEnabled && + remoteProxyConnectionString && + bindings.browser?.experimental_remote ? { binding: bindings.browser.binding, - mixedModeConnectionString, + remoteProxyConnectionString, } : undefined, vectorize: - mixedModeEnabled && mixedModeConnectionString + remoteBindingsEnabled && remoteProxyConnectionString ? Object.fromEntries( bindings.vectorize ?.filter((v) => { - warnOrError("vectorize", v.remote, "remote"); - return v.remote; + warnOrError("vectorize", v.experimental_remote, "remote"); + return v.experimental_remote; }) .map((vectorize) => { return [ vectorize.binding, { index_name: vectorize.index_name, - mixedModeConnectionString, + remoteProxyConnectionString, }, ]; }) ?? [] @@ -997,17 +1010,21 @@ export function buildMiniflareBindingOptions( : undefined, dispatchNamespaces: - mixedModeEnabled && mixedModeConnectionString + remoteBindingsEnabled && remoteProxyConnectionString ? Object.fromEntries( bindings.dispatch_namespaces ?.filter((d) => { - warnOrError("dispatch_namespaces", d.remote, "remote"); - return d.remote; + warnOrError( + "dispatch_namespaces", + d.experimental_remote, + "remote" + ); + return d.experimental_remote; }) .map((dispatchNamespace) => dispatchNamespaceEntry( dispatchNamespace, - mixedModeConnectionString + remoteProxyConnectionString ) ) ?? [] ) @@ -1061,17 +1078,21 @@ export function buildMiniflareBindingOptions( ), mtlsCertificates: - mixedModeEnabled && mixedModeConnectionString + remoteBindingsEnabled && remoteProxyConnectionString ? Object.fromEntries( bindings.mtls_certificates ?.filter((d) => { - warnOrError("mtls_certificates", d.remote, "remote"); - return d.remote; + warnOrError( + "mtls_certificates", + d.experimental_remote, + "remote" + ); + return d.experimental_remote; }) .map((mtlsCertificate) => [ mtlsCertificate.binding, { - mixedModeConnectionString, + remoteProxyConnectionString, certificate_id: mtlsCertificate.certificate_id, }, ]) ?? [] @@ -1267,8 +1288,8 @@ export async function buildMiniflareOptions( log: Log, config: Omit, proxyToUserWorkerAuthenticationSecret: UUID, - mixedModeConnectionString: MixedModeConnectionString | undefined, - mixedModeEnabled: boolean + remoteProxyConnectionString: RemoteProxyConnectionString | undefined, + remoteBindingsEnabled: boolean ): Promise<{ options: Options; internalObjects: CfDurableObject[]; @@ -1283,7 +1304,7 @@ export async function buildMiniflareOptions( } } - if (!mixedModeEnabled) { + if (!remoteBindingsEnabled) { if (config.bindings.ai) { if (!didWarnAiAccountUsage) { didWarnAiAccountUsage = true; @@ -1319,8 +1340,8 @@ export async function buildMiniflareOptions( const { bindingOptions, internalObjects, externalWorkers } = buildMiniflareBindingOptions( config, - mixedModeConnectionString, - mixedModeEnabled + remoteProxyConnectionString, + remoteBindingsEnabled ); const sitesOptions = buildSitesOptions(config); const defaultPersistRoot = getDefaultPersistRoot(config.localPersistencePath); diff --git a/packages/wrangler/src/experimental-flags.ts b/packages/wrangler/src/experimental-flags.ts index 6b077b67bab5..f52b27b6f4d6 100644 --- a/packages/wrangler/src/experimental-flags.ts +++ b/packages/wrangler/src/experimental-flags.ts @@ -4,7 +4,7 @@ import { logger } from "./logger"; export type ExperimentalFlags = { MULTIWORKER: boolean; RESOURCES_PROVISION: boolean; - MIXED_MODE: boolean; + REMOTE_BINDINGS: boolean; }; const flags = new AsyncLocalStorage(); diff --git a/packages/wrangler/src/index.ts b/packages/wrangler/src/index.ts index 5e4de323cc6c..3f6b3cad5945 100644 --- a/packages/wrangler/src/index.ts +++ b/packages/wrangler/src/index.ts @@ -427,17 +427,17 @@ export function createCLIParser(argv: string[]) { return true; }) - .option("experimental-provision", { - describe: `Experimental: Enable automatic resource provisioning`, + .option("experimental-remote-bindings", { + describe: `Experimental: Enable Remote Bindings`, type: "boolean", hidden: true, - alias: ["x-provision"], + alias: ["x-remote-bindings"], }) - .option("experimental-mixed-mode", { - describe: `Experimental: Enable Mixed Mode`, + .option("experimental-provision", { + describe: `Experimental: Enable automatic resource provisioning`, type: "boolean", hidden: true, - alias: ["x-mixed-mode"], + alias: ["x-provision"], }) .epilogue( `Please report any issues to ${chalk.hex("#3B818D")( diff --git a/packages/wrangler/src/pages/dev.ts b/packages/wrangler/src/pages/dev.ts index 75a5824c818e..8eaf70119346 100644 --- a/packages/wrangler/src/pages/dev.ts +++ b/packages/wrangler/src/pages/dev.ts @@ -882,7 +882,7 @@ export const pagesDevCommand = createCommand({ { MULTIWORKER: Array.isArray(args.config), RESOURCES_PROVISION: false, - MIXED_MODE: false, + REMOTE_BINDINGS: false, }, () => startDev({ @@ -948,7 +948,7 @@ export const pagesDevCommand = createCommand({ persistTo: args.persistTo, logLevel: args.logLevel ?? "log", experimentalProvision: undefined, - experimentalMixedMode: false, + experimentalRemoteBindings: false, 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 41e4dfe5b7aa..637a25e7b770 100644 --- a/packages/wrangler/src/utils/print-bindings.ts +++ b/packages/wrangler/src/utils/print-bindings.ts @@ -160,31 +160,35 @@ export function printBindings( if (workflows !== undefined && workflows.length > 0) { output.push( - ...workflows.map(({ class_name, script_name, binding, remote }) => { - let value = class_name; - if (script_name) { - value += ` (defined in ${script_name})`; - } + ...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 ? !remote : true }), - }; - }) + return { + name: binding, + type: friendlyBindingNames.workflows, + value: value, + mode: getMode({ + isSimulatedLocally: script_name ? !experimental_remote : true, + }), + }; + } + ) ); } if (kv_namespaces !== undefined && kv_namespaces.length > 0) { output.push( - ...kv_namespaces.map(({ binding, id, remote }) => { + ...kv_namespaces.map(({ binding, id, experimental_remote }) => { return { name: binding, type: friendlyBindingNames.kv_namespaces, value: id, mode: getMode({ - isSimulatedLocally: !remote, + isSimulatedLocally: !experimental_remote, }), }; }) @@ -217,13 +221,13 @@ export function printBindings( if (queues !== undefined && queues.length > 0) { output.push( - ...queues.map(({ binding, queue_name, remote }) => { + ...queues.map(({ binding, queue_name, experimental_remote }) => { return { name: binding, type: friendlyBindingNames.queues, value: queue_name, mode: getMode({ - isSimulatedLocally: !remote, + isSimulatedLocally: !experimental_remote, }), }; }) @@ -238,7 +242,7 @@ export function printBindings( database_name, database_id, preview_database_id, - remote, + experimental_remote, }) => { const value = typeof database_id == "symbol" @@ -249,7 +253,7 @@ export function printBindings( name: binding, type: friendlyBindingNames.d1_databases, mode: getMode({ - isSimulatedLocally: !remote, + isSimulatedLocally: !experimental_remote, }), value, }; @@ -260,14 +264,14 @@ export function printBindings( if (vectorize !== undefined && vectorize.length > 0) { output.push( - ...vectorize.map(({ binding, index_name, remote }) => { + ...vectorize.map(({ binding, index_name, experimental_remote }) => { return { name: binding, type: friendlyBindingNames.vectorize, value: index_name, mode: getMode({ - isSimulatedLocally: getFlag("MIXED_MODE") - ? remote + isSimulatedLocally: getFlag("REMOTE_BINDINGS") + ? experimental_remote ? false : undefined : context.vectorizeBindToProd @@ -294,23 +298,25 @@ export function printBindings( if (r2_buckets !== undefined && r2_buckets.length > 0) { output.push( - ...r2_buckets.map(({ binding, bucket_name, jurisdiction, remote }) => { - const value = - typeof bucket_name === "symbol" - ? bucket_name - : bucket_name - ? `${bucket_name}${jurisdiction ? ` (${jurisdiction})` : ""}` - : undefined; + ...r2_buckets.map( + ({ binding, bucket_name, jurisdiction, experimental_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: !remote, - }), - }; - }) + return { + name: binding, + type: friendlyBindingNames.r2_buckets, + value: value, + mode: getMode({ + isSimulatedLocally: !experimental_remote, + }), + }; + } + ) ); } @@ -355,38 +361,40 @@ export function printBindings( if (services !== undefined && services.length > 0) { output.push( - ...services.map(({ binding, service, entrypoint, remote }) => { - let value = service; - let mode = undefined; + ...services.map( + ({ binding, service, entrypoint, experimental_remote }) => { + let value = service; + let mode = undefined; - if (entrypoint) { - value += `#${entrypoint}`; - } + if (entrypoint) { + value += `#${entrypoint}`; + } - 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 }); + if (experimental_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, + }; + } + ) ); } @@ -424,7 +432,9 @@ export function printBindings( value: undefined, mode: getMode({ isSimulatedLocally: - getFlag("MIXED_MODE") && browser.remote ? false : undefined, + getFlag("REMOTE_BINDINGS") && browser.experimental_remote + ? false + : undefined, }), }); } @@ -435,8 +445,9 @@ export function printBindings( type: friendlyBindingNames.images, value: undefined, mode: getMode({ - isSimulatedLocally: getFlag("MIXED_MODE") - ? images.remote === true || images.remote === undefined + isSimulatedLocally: getFlag("REMOTE_BINDINGS") + ? images.experimental_remote === true || + images.experimental_remote === undefined ? false : undefined : !!context.imagesLocalMode, @@ -450,8 +461,9 @@ export function printBindings( type: friendlyBindingNames.ai, value: ai.staging ? `staging` : undefined, mode: getMode({ - isSimulatedLocally: getFlag("MIXED_MODE") - ? ai.remote === true || ai.remote === undefined + isSimulatedLocally: getFlag("REMOTE_BINDINGS") + ? ai.experimental_remote === true || + ai.experimental_remote === undefined ? false : undefined : false, @@ -533,41 +545,46 @@ export function printBindings( if (dispatch_namespaces !== undefined && dispatch_namespaces.length > 0) { output.push( - ...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("MIXED_MODE") - ? remote - ? false - : undefined - : undefined, - }), - }; - }) + ...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, + }), + }; + } + ) ); } if (mtls_certificates !== undefined && mtls_certificates.length > 0) { output.push( - ...mtls_certificates.map(({ binding, certificate_id, remote }) => { - return { - name: binding, - type: friendlyBindingNames.mtls_certificates, - value: certificate_id, - mode: getMode({ - isSimulatedLocally: getFlag("MIXED_MODE") - ? remote === true || remote === undefined - ? false - : undefined - : false, - }), - }; - }) + ...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, + }), + }; + } + ) ); } @@ -766,17 +783,17 @@ 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 \`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 \`experimental_remote: true\` for the binding definition in your configuration file to access a remote version of the resource.` ); } 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 \`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 \`experimental_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 \`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 \`experimental_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 db74d09bf932..80e91e49b06e 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, - MIXED_MODE: false, + REMOTE_BINDINGS: false, }), warnIfMultipleEnvsConfiguredButNoneSpecified: true, }, diff --git a/packages/wrangler/src/yargs-types.ts b/packages/wrangler/src/yargs-types.ts index 02ec4dd49596..f155d0635800 100644 --- a/packages/wrangler/src/yargs-types.ts +++ b/packages/wrangler/src/yargs-types.ts @@ -10,7 +10,7 @@ export interface CommonYargsOptions { config: string | undefined; env: string | undefined; "experimental-provision": boolean | undefined; - "experimental-mixed-mode": boolean | undefined; + "experimental-remote-bindings": boolean | undefined; } /** diff --git a/packages/wrangler/templates/mixedMode/proxyServerWorker/index.ts b/packages/wrangler/templates/remoteBindings/proxyServerWorker/index.ts similarity index 100% rename from packages/wrangler/templates/mixedMode/proxyServerWorker/index.ts rename to packages/wrangler/templates/remoteBindings/proxyServerWorker/index.ts diff --git a/packages/wrangler/templates/mixedMode/proxyServerWorker/wrangler.jsonc b/packages/wrangler/templates/remoteBindings/proxyServerWorker/wrangler.jsonc similarity index 100% rename from packages/wrangler/templates/mixedMode/proxyServerWorker/wrangler.jsonc rename to packages/wrangler/templates/remoteBindings/proxyServerWorker/wrangler.jsonc diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ceb581dd68fc..464e1a31fd93 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1036,7 +1036,7 @@ importers: specifier: workspace:* version: link:../../packages/wrangler - fixtures/vitest-pool-workers-mixed-mode: + fixtures/vitest-pool-workers-remote-bindings: devDependencies: '@cloudflare/vitest-pool-workers': specifier: workspace:* @@ -8536,9 +8536,6 @@ packages: es-iterator-helpers@1.0.15: resolution: {integrity: sha512-GhoY8uYqd6iwUl2kgjTm4CZAf6oo5mHK7BPqx3rKgx893YSsy0LGHV6gfqqQvZt/8xM8xeOnfXBCfqclMKkJ5g==} - es-module-lexer@1.5.4: - resolution: {integrity: sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==} - es-module-lexer@1.7.0: resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==} @@ -10074,9 +10071,6 @@ packages: resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} hasBin: true - loupe@3.1.2: - resolution: {integrity: sha512-23I4pFZHmAemUnz8WZXbYRSKYj801VDaNv9ETuMh7IrMc7VuVVSo+Z9iLE3ni30+U48iDWfi30d3twAXBYmnCg==} - loupe@3.1.3: resolution: {integrity: sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug==} @@ -13687,7 +13681,7 @@ snapshots: '@babel/traverse': 7.25.9 '@babel/types': 7.26.3 convert-source-map: 2.0.0 - debug: 4.4.0(supports-color@9.2.2) + debug: 4.4.1(supports-color@9.2.2) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -13781,7 +13775,7 @@ snapshots: '@babel/parser': 7.26.3 '@babel/template': 7.25.9 '@babel/types': 7.26.3 - debug: 4.4.0(supports-color@9.2.2) + debug: 4.4.1(supports-color@9.2.2) globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -17308,7 +17302,7 @@ snapshots: '@vitest/utils@2.1.9': dependencies: '@vitest/pretty-format': 2.1.9 - loupe: 3.1.2 + loupe: 3.1.3 tinyrainbow: 1.2.0 '@vitest/utils@3.0.9': @@ -17483,7 +17477,7 @@ snapshots: agent-base@6.0.2(supports-color@9.2.2): dependencies: - debug: 4.4.0(supports-color@9.2.2) + debug: 4.4.1(supports-color@9.2.2) transitivePeerDependencies: - supports-color @@ -17841,7 +17835,7 @@ snapshots: dependencies: bytes: 3.1.2 content-type: 1.0.5 - debug: 4.4.0(supports-color@9.2.2) + debug: 4.4.1(supports-color@9.2.2) http-errors: 2.0.0 iconv-lite: 0.6.3 on-finished: 2.4.1 @@ -17976,7 +17970,7 @@ snapshots: assertion-error: 2.0.1 check-error: 2.1.1 deep-eql: 5.0.2 - loupe: 3.1.2 + loupe: 3.1.3 pathval: 2.0.0 chai@5.2.0: @@ -18757,8 +18751,6 @@ snapshots: iterator.prototype: 1.1.2 safe-array-concat: 1.1.2 - es-module-lexer@1.5.4: {} - es-module-lexer@1.7.0: {} es-object-atoms@1.0.0: @@ -19484,7 +19476,7 @@ snapshots: finalhandler@2.1.0: dependencies: - debug: 4.4.0(supports-color@9.2.2) + debug: 4.4.1(supports-color@9.2.2) encodeurl: 2.0.0 escape-html: 1.0.3 on-finished: 2.4.1 @@ -19872,7 +19864,7 @@ snapshots: https-proxy-agent@5.0.1(supports-color@9.2.2): dependencies: agent-base: 6.0.2(supports-color@9.2.2) - debug: 4.4.0(supports-color@9.2.2) + debug: 4.4.1(supports-color@9.2.2) transitivePeerDependencies: - supports-color @@ -20529,8 +20521,6 @@ snapshots: dependencies: js-tokens: 4.0.0 - loupe@3.1.2: {} - loupe@3.1.3: {} lowdb@1.0.0: @@ -22022,7 +22012,7 @@ snapshots: router@2.2.0: dependencies: - debug: 4.4.0(supports-color@9.2.2) + debug: 4.4.1(supports-color@9.2.2) depd: 2.0.0 is-promise: 4.0.0 parseurl: 1.3.3 @@ -22126,7 +22116,7 @@ snapshots: send@1.2.0: dependencies: - debug: 4.4.0(supports-color@9.2.2) + debug: 4.4.1(supports-color@9.2.2) encodeurl: 2.0.0 escape-html: 1.0.3 etag: 1.8.1 @@ -23212,8 +23202,8 @@ snapshots: vite-node@2.1.9(@types/node@20.17.32)(lightningcss@1.29.2): dependencies: cac: 6.7.14 - debug: 4.4.0(supports-color@9.2.2) - es-module-lexer: 1.5.4 + debug: 4.4.1(supports-color@9.2.2) + es-module-lexer: 1.7.0 pathe: 1.1.2 vite: 5.4.14(@types/node@20.17.32)(lightningcss@1.29.2) transitivePeerDependencies: