Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/nice-falcons-yell.md
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 0 additions & 7 deletions fixtures/vitest-pool-workers-mixed-mode/remote-worker.js

This file was deleted.

8 changes: 0 additions & 8 deletions fixtures/vitest-pool-workers-mixed-mode/wrangler.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 7 additions & 0 deletions fixtures/vitest-pool-workers-remote-bindings/remote-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
fetch() {
return new Response(
"Hello from a remote Worker part of the vitest-pool-workers remote bindings fixture!"
);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ 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!"`
);
}
);

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!"`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
experimental_mixedMode: true,
experimental_remoteBindings: true,
wrangler: { configPath: "./wrangler.json" },
},
},
Expand Down
12 changes: 12 additions & 0 deletions fixtures/vitest-pool-workers-remote-bindings/wrangler.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
16 changes: 8 additions & 8 deletions packages/miniflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -2196,7 +2196,7 @@ export class Miniflare {
workerOpts.do.durableObjects ?? {}
).reduce<WorkerDefinition["durableObjects"]>(
(internalObjects, [bindingName, designator]) => {
const { className, scriptName, mixedModeConnectionString } =
const { className, scriptName, remoteProxyConnectionString } =
normaliseDurableObject(designator);

if (
Expand All @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions packages/miniflare/src/plugins/ai/index.ts
Original file line number Diff line number Diff line change
@@ -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<MixedModeConnectionString>(),
remoteProxyConnectionString: z.custom<RemoteProxyConnectionString>(),
});

export const AIOptionsSchema = z.object({
Expand All @@ -26,8 +26,8 @@ export const AI_PLUGIN: Plugin<typeof AIOptionsSchema> = {
}

assert(
options.ai.mixedModeConnectionString,
"Workers AI only supports Mixed Mode"
options.ai.remoteProxyConnectionString,
"Workers AI only supports running remotely"
);

return [
Expand Down Expand Up @@ -61,8 +61,8 @@ export const AI_PLUGIN: Plugin<typeof AIOptionsSchema> = {
return [
{
name: `${AI_PLUGIN_NAME}:${options.ai.binding}`,
worker: mixedModeClientWorker(
options.ai.mixedModeConnectionString,
worker: remoteProxyClientWorker(
options.ai.remoteProxyConnectionString,
options.ai.binding
),
},
Expand Down
18 changes: 9 additions & 9 deletions packages/miniflare/src/plugins/browser-rendering/index.ts
Original file line number Diff line number Diff line change
@@ -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<MixedModeConnectionString>(),
remoteProxyConnectionString: z.custom<RemoteProxyConnectionString>(),
});

export const BrowserRenderingOptionsSchema = z.object({
Expand All @@ -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 [
Expand All @@ -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
),
},
Expand Down
17 changes: 10 additions & 7 deletions packages/miniflare/src/plugins/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
),
};
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/miniflare/src/plugins/core/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Request, Response } from "../../http";
import {
HOST_CAPNP_CONNECT,
Miniflare,
MixedModeConnectionString,
RemoteProxyConnectionString,
} from "../../index";
import {
ExternalServer,
Expand Down Expand Up @@ -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<MixedModeConnectionString>().optional(),
remoteProxyConnectionString: z
.custom<RemoteProxyConnectionString>()
.optional(),
}),
z.object({ network: NetworkSchema }),
z.object({ external: ExternalServerSchema }),
Expand Down
20 changes: 10 additions & 10 deletions packages/miniflare/src/plugins/d1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import {
getMiniflareObjectBindings,
getPersistPath,
migrateDatabase,
mixedModeClientWorker,
MixedModeConnectionString,
namespaceEntries,
namespaceKeys,
objectEntryWorker,
PersistenceSchema,
Plugin,
ProxyNodeBinding,
remoteProxyClientWorker,
RemoteProxyConnectionString,
SERVICE_LOOPBACK,
} from "../shared";

Expand All @@ -30,8 +30,8 @@ export const D1OptionsSchema = z.object({
z.record(
z.object({
id: z.string(),
mixedModeConnectionString: z
.custom<MixedModeConnectionString>()
remoteProxyConnectionString: z
.custom<RemoteProxyConnectionString>()
.optional(),
})
),
Expand Down Expand Up @@ -61,10 +61,10 @@ export const D1_PLUGIN: Plugin<
getBindings(options) {
const databases = namespaceEntries(options.d1Databases);
return databases.map<Worker_Binding>(
([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__")
Expand Down Expand Up @@ -106,10 +106,10 @@ export const D1_PLUGIN: Plugin<
const persist = sharedOptions.d1Persist;
const databases = namespaceEntries(options.d1Databases);
const services = databases.map<Service>(
([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),
})
);
Expand Down
Loading
Loading