Skip to content
16 changes: 6 additions & 10 deletions fixtures/get-platform-proxy-remote-bindings/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ if (auth) {
{
binding: "MY_WORKER",
service: remoteWorkerName,
experimental_remote: true,
remote: true,
},
],
kv_namespaces: [
{
binding: "MY_KV",
id: remoteKvId,
experimental_remote: true,
remote: true,
},
],
env: {
Expand All @@ -108,14 +108,14 @@ if (auth) {
{
binding: "MY_WORKER",
service: remoteStagingWorkerName,
experimental_remote: true,
remote: true,
},
],
kv_namespaces: [
{
binding: "MY_KV",
id: remoteKvId,
experimental_remote: true,
remote: true,
},
],
},
Expand All @@ -137,7 +137,6 @@ if (auth) {
MY_KV: KVNamespace;
}>({
configPath: "./.tmp/normal-usage/wrangler.json",
experimental: { remoteBindings: true },
});

const response = await fetchFromWorker(env.MY_WORKER, "OK");
Expand All @@ -160,7 +159,6 @@ if (auth) {
MY_KV: KVNamespace;
}>({
configPath: "./.tmp/normal-usage/wrangler.json",
experimental: { remoteBindings: true },
environment: "staging",
});

Expand Down Expand Up @@ -219,7 +217,7 @@ if (auth) {
{
binding: "MY_WORKER",
service: remoteWorkerName,
experimental_remote: true,
remote: true,
},
],
},
Expand All @@ -233,7 +231,6 @@ if (auth) {
MY_WORKER: Fetcher;
}>({
configPath: "./.tmp/config-with-invalid-account-id/wrangler.json",
experimental: { remoteBindings: true },
});

const response = await fetchFromWorker(env.MY_WORKER, "OK", 10_000);
Expand All @@ -257,7 +254,7 @@ if (auth) {
{
binding: "MY_WORKER",
service: remoteWorkerName,
experimental_remote: true,
remote: true,
},
],
},
Expand All @@ -271,7 +268,6 @@ if (auth) {
MY_WORKER: Fetcher;
}>({
configPath: "./.tmp/config-with-no-account-id/wrangler.json",
experimental: { remoteBindings: true },
});

const response = await fetchFromWorker(env.MY_WORKER, "OK");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineWorkersConfig({
include: ["test-staging/**/*.spec.ts"],
poolOptions: {
workers: {
experimental_remoteBindings: true,
remoteBindings: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this field still supposed to be here? in vitest.workers.config.ts it's removed entirely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No—removed now

wrangler: { configPath: "./wrangler.json", environment: "staging" },
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default defineWorkersConfig({
include: ["test/**/*.spec.ts"],
poolOptions: {
workers: {
experimental_remoteBindings: true,
wrangler: { configPath: "./wrangler.json" },
},
},
Expand Down
4 changes: 2 additions & 2 deletions fixtures/vitest-pool-workers-remote-bindings/wrangler.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"binding": "MY_WORKER",
"service": "my-worker-test",
"experimental_remote": true
"remote": true
}
],
"env": {
Expand All @@ -15,7 +15,7 @@
{
"binding": "MY_WORKER",
"service": "my-staging-worker-test",
"experimental_remote": true
"remote": true
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"binding": "REMOTE_WORKER",
"service": "<<REMOTE_WORKER_PLACEHOLDER_ALT>>",
"experimental_remote": true,
"remote": true,
},
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
{
"binding": "LOCAL_WORKER",
"service": "cloudflare-vite-e2e-remote-bindings-auxiliary-worker",
"experimental_remote": false,
"remote": false,
},
{
"binding": "REMOTE_WORKER",
"service": "<<REMOTE_WORKER_PLACEHOLDER>>",
"experimental_remote": true,
"remote": true,
},
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default defineConfig({
],
inspectorPort: false,
persistState: false,
experimental: { remoteBindings: true },
}),
],
});
48 changes: 24 additions & 24 deletions packages/vite-plugin-cloudflare/src/miniflare-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import type {
import type { MiniflareOptions, WorkerOptions } from "miniflare";
import type { FetchFunctionOptions } from "vite/module-runner";
import type {
Experimental_RemoteProxySession,
remoteProxySession,
SourcelessWorkerOptions,
Unstable_Binding,
} from "wrangler";
Expand Down Expand Up @@ -230,7 +230,7 @@ function logUnknownTails(
const remoteProxySessionsDataMap = new Map<
string,
{
session: Experimental_RemoteProxySession;
session: remoteProxySession;
remoteBindings: Record<string, Unstable_Binding>;
} | null
>();
Expand Down Expand Up @@ -396,16 +396,16 @@ export async function getDevMiniflareOptions(config: {
? remoteProxySessionsDataMap.get(workerConfig.configPath)
: undefined;

const remoteProxySessionData = resolvedPluginConfig.experimental
.remoteBindings
? await experimental_maybeStartOrUpdateRemoteProxySession(
{
name: workerConfig.name,
bindings: bindings ?? {},
},
preExistingRemoteProxySession ?? null
)
: undefined;
const remoteProxySessionData =
resolvedPluginConfig.experimental.remoteBindings ?? true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this experimental property still valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see #10604 (comment)

? await experimental_maybeStartOrUpdateRemoteProxySession(
{
name: workerConfig.name,
bindings: bindings ?? {},
},
preExistingRemoteProxySession ?? null
)
: undefined;

if (workerConfig.configPath && remoteProxySessionData) {
remoteProxySessionsDataMap.set(
Expand All @@ -425,7 +425,7 @@ export async function getDevMiniflareOptions(config: {
remoteProxySessionData?.session
?.remoteProxyConnectionString,
remoteBindingsEnabled:
resolvedPluginConfig.experimental.remoteBindings,
resolvedPluginConfig.experimental.remoteBindings ?? true,
containerBuildId,
}
);
Expand Down Expand Up @@ -726,16 +726,16 @@ export async function getPreviewMiniflareOptions(config: {
? remoteProxySessionsDataMap.get(workerConfig.configPath)
: undefined;

const remoteProxySessionData = resolvedPluginConfig.experimental
.remoteBindings
? await experimental_maybeStartOrUpdateRemoteProxySession(
{
name: workerConfig.name,
bindings: bindings ?? {},
},
preExistingRemoteProxySessionData ?? null
)
: undefined;
const remoteProxySessionData =
resolvedPluginConfig.experimental.remoteBindings ?? true
? await experimental_maybeStartOrUpdateRemoteProxySession(
{
name: workerConfig.name,
bindings: bindings ?? {},
},
preExistingRemoteProxySessionData ?? null
)
: undefined;

if (workerConfig.configPath && remoteProxySessionData) {
remoteProxySessionsDataMap.set(
Expand All @@ -751,7 +751,7 @@ export async function getPreviewMiniflareOptions(config: {
remoteProxyConnectionString:
remoteProxySessionData?.session?.remoteProxyConnectionString,
remoteBindingsEnabled:
resolvedPluginConfig.experimental.remoteBindings,
resolvedPluginConfig.experimental.remoteBindings ?? true,
containerBuildId,
}
);
Expand Down
15 changes: 6 additions & 9 deletions packages/vitest-pool-workers/src/pool/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import { getProjectPath, getRelativeProjectPath } from "./helpers";
import type { ModuleRule, WorkerOptions } from "miniflare";
import type { ProvidedContext } from "vitest";
import type { WorkspaceProject } from "vitest/node";
import type {
Experimental_RemoteProxySession,
Unstable_Binding,
} from "wrangler";
import type { remoteProxySession, Unstable_Binding } from "wrangler";
import type { ParseParams, ZodError } from "zod";

export interface WorkersConfigPluginAPI {
Expand Down Expand Up @@ -49,9 +46,9 @@ const WorkersPoolOptionsSchema = z.object({
isolatedStorage: z.boolean().default(true),
/**
* Enables experimental remote bindings to access remote resources configured
* with `experimental_experimental_remote: true` in the wrangler configuration file.
* with `experimental_remote: true` in the wrangler configuration file.
*/
experimental_remoteBindings: z.boolean().optional(),
remoteBindings: z.boolean().default(true).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
Expand Down Expand Up @@ -184,7 +181,7 @@ function filterTails(
const remoteProxySessionsDataMap = new Map<
string,
{
session: Experimental_RemoteProxySession;
session: remoteProxySession;
remoteBindings: Record<string, Unstable_Binding>;
} | null
>();
Expand Down Expand Up @@ -257,7 +254,7 @@ async function parseCustomPoolOptions(
? remoteProxySessionsDataMap.get(options.wrangler.configPath)
: undefined;

const remoteProxySessionData = options.experimental_remoteBindings
const remoteProxySessionData = options.remoteBindings
? await wrangler.experimental_maybeStartOrUpdateRemoteProxySession(
{
path: options.wrangler.configPath,
Expand Down Expand Up @@ -285,7 +282,7 @@ async function parseCustomPoolOptions(
// doesn't work with containers yet so let's just disable it
enableContainers: false,
},
remoteBindingsEnabled: options.experimental_remoteBindings,
remoteBindingsEnabled: options.remoteBindings,
remoteProxyConnectionString:
remoteProxySessionData?.session?.remoteProxyConnectionString,
}
Expand Down
Loading
Loading