Skip to content

Commit f90ce67

Browse files
lrapoport-cfarunesh90penalosa
authored
Update remote bindings to remove experimental (#25064)
* Update remote bindings to remove experimental * Update src/content/docs/workers/development-testing/index.mdx Co-authored-by: Arunesh <[email protected]> * Update APIs * Fix formatting * Add support note * fix formatting --------- Co-authored-by: Arunesh <[email protected]> Co-authored-by: Samuel Macleod <[email protected]>
1 parent 5201503 commit f90ce67

File tree

1 file changed

+49
-91
lines changed
  • src/content/docs/workers/development-testing

1 file changed

+49
-91
lines changed

src/content/docs/workers/development-testing/index.mdx

Lines changed: 49 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ During local development, your Worker code interacts with these bindings using t
6767
- By default, bindings connect to **local resource simulations** (except for [AI bindings](/workers-ai/configuration/bindings/), as AI models always run remotely).
6868
- You can override this default behavior and **connect to the remote resource**, on a per-binding basis. This lets you connect to real, production resources while still running your Worker code locally.
6969

70-
## Remote bindings <InlineBadge preset="beta"/>
70+
## Remote bindings
7171

72-
**Remote bindings** are bindings that are configured to connect to the deployed, remote resource during local development _instead_ of the locally simulated resource. You can configure remote bindings by setting `experimental_remote: true` in the binding definition.
72+
**Remote bindings** are bindings that are configured to connect to the deployed, remote resource during local development _instead_ of the locally simulated resource. Remote bindings are supported by [**Wrangler**](/workers/wrangler/), the [**Cloudflare Vite plugin**](/workers/vite-plugin/), and the `@cloudflare/vitest-pool-workers` package. You can configure remote bindings by setting `remote: true` in the binding definition.
7373

7474
### Example configuration
7575

@@ -84,58 +84,15 @@ During local development, your Worker code interacts with these bindings using t
8484
{
8585
"bucket_name": "screenshots-bucket",
8686
"binding": "screenshots_bucket",
87-
"experimental_remote": true,
87+
"remote": true,
8888
},
8989
],
9090
}
9191
```
9292

9393
</WranglerConfig>
9494

95-
When remote bindings are configured, your Worker still **executes locally**, only the underlying resources your bindings connect to change. For all bindings marked with `experimental_remote: true`, Miniflare will route its operations (such as `env.MY_KV.put()`) to the deployed resource. All other bindings not explicitly configured with `experimental_remote: true` continue to use their default local simulations.
96-
97-
### Using Wrangler with remote bindings
98-
99-
If you're using [Wrangler](/workers/wrangler/) for local development and have remote bindings configured, you'll need to use the following experimental command:
100-
101-
<PackageManagers type="exec" pkg="wrangler" args="dev --x-remote-bindings" />
102-
103-
### Using Vite with remote bindings
104-
105-
If you're using Vite via [the Cloudflare Vite plugin](/workers/vite-plugin/), you'll need to add support for remote bindings in your Vite configuration (`vite.config.ts`):
106-
107-
```ts title="vite.config.ts" {8}
108-
import { cloudflare } from "@cloudflare/vite-plugin";
109-
import { defineConfig } from "vite";
110-
111-
export default defineConfig({
112-
plugins: [
113-
cloudflare({
114-
configPath: "wrangler.jsonc",
115-
experimental: { remoteBindings: true },
116-
}),
117-
],
118-
});
119-
```
120-
121-
### Using Vitest with remote bindings
122-
123-
You can also use Vitest with configured remote bindings by enabling support in your Vitest configuration file (`vitest.config.ts`):
124-
125-
```ts title="vitest.config.ts" {7}
126-
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
127-
128-
export default defineWorkersConfig({
129-
test: {
130-
poolOptions: {
131-
workers: {
132-
experimental_remoteBindings: true,
133-
wrangler: { configPath: "./wrangler.jsonc" },
134-
},
135-
},
136-
},
137-
});
138-
```
95+
When remote bindings are configured, your Worker still **executes locally**, only the underlying resources your bindings connect to change. For all bindings marked with `remote: true`, Miniflare will route its operations (such as `env.MY_KV.put()`) to the deployed resource. All other bindings not explicitly configured with `remote: true` continue to use their default local simulations.
13996

14097
### Targeting preview resources
14198

@@ -145,7 +102,7 @@ To protect production data, you can create and specify preview resources in your
145102
- [Preview buckets for R2 storage](/workers/wrangler/configuration/#r2-buckets): `preview_bucket_name`.
146103
- [Preview database IDs for D1](/workers/wrangler/configuration/#d1-databases): `preview_database_id`
147104

148-
If preview configuration is present for a binding, setting `experimental_remote: true` will ensure that remote bindings connect to that designated remote preview resource.
105+
If preview configuration is present for a binding, setting `remote: true` will ensure that remote bindings connect to that designated remote preview resource.
149106

150107
**For example:**
151108

@@ -161,15 +118,15 @@ If preview configuration is present for a binding, setting `experimental_remote:
161118
"bucket_name": "screenshots-bucket",
162119
"binding": "screenshots_bucket",
163120
"preview_bucket_name": "preview-screenshots-bucket",
164-
"experimental_remote": true,
121+
"remote": true,
165122
},
166123
],
167124
}
168125
```
169126

170127
</WranglerConfig>
171128

172-
Running `wrangler dev --x-remote-bindings` with the above configuration means that:
129+
Running `wrangler dev` with the above configuration means that:
173130

174131
- Your Worker code runs locally
175132
- All calls made to `env.screenshots_bucket` will use the `preview-screenshots-bucket` resource, rather than the production `screenshots-bucket`.
@@ -178,7 +135,7 @@ Running `wrangler dev --x-remote-bindings` with the above configuration means th
178135

179136
We recommend configuring specific bindings to connect to their remote counterparts. These services often rely on Cloudflare's network infrastructure or have complex backends that are not fully simulated locally.
180137

181-
The following bindings are recommended to have `experimental_remote: true` in your Wrangler configuration:
138+
The following bindings are recommended to have `remote: true` in your Wrangler configuration:
182139

183140
#### [Browser Rendering](/workers/wrangler/configuration/#browser-rendering):
184141

@@ -189,7 +146,7 @@ To interact with a real headless browser for rendering. There is no current loca
189146
{
190147
"browser": {
191148
"binding": "MY_BROWSER",
192-
"experimental_remote": true
149+
"remote": true
193150
},
194151
}
195152
```
@@ -204,7 +161,7 @@ To utilize actual AI models deployed on Cloudflare's network for inference. Ther
204161
{
205162
"ai": {
206163
"binding": "AI",
207-
"experimental_remote": true
164+
"remote": true
208165
},
209166
}
210167
```
@@ -221,7 +178,7 @@ To connect to your production Vectorize indexes for accurate vector search and s
221178
{
222179
"binding": "MY_VECTORIZE_INDEX",
223180
"index_name": "my-prod-index",
224-
"experimental_remote": true
181+
"remote": true
225182
}
226183
],
227184
}
@@ -239,12 +196,12 @@ To verify that the certificate exchange and validation process work as expected.
239196
{
240197
"binding": "MY_CLIENT_CERT_FETCHER",
241198
"certificate_id": "<YOUR_UPLOADED_CERT_ID>",
242-
"experimental_remote": true
199+
"remote": true
243200
}
244201
]
245202
}
246203

247-
```
204+
````
248205
</WranglerConfig>
249206

250207
#### [Images](/workers/wrangler/configuration/#images):
@@ -256,22 +213,22 @@ To connect to a high-fidelity version of the Images API, and verify that all tra
256213
{
257214
"images": {
258215
"binding": "IMAGES" ,
259-
"experimental_remote": true
216+
"remote": true
260217
}
261218
}
262-
```
219+
````
263220
264221
</WranglerConfig>
265222
266223
:::note
267-
If `experimental_remote: true` is not specified for Browser Rendering, Vectorize, mTLS, or Images, Cloudflare **will issue a warning**. This prompts you to consider enabling it for a more production-like testing experience.
224+
If `remote: true` is not specified for Browser Rendering, Vectorize, mTLS, or Images, Cloudflare **will issue a warning**. This prompts you to consider enabling it for a more production-like testing experience.
268225
269-
If a Workers AI binding has `experimental_remote` set to `false`, Cloudflare will **produce an error**. If the property is omitted, Cloudflare will connect to the remote resource and issue a warning to add the property to configuration.
226+
If a Workers AI binding has `remote` set to `false`, Cloudflare will **produce an error**. If the property is omitted, Cloudflare will connect to the remote resource and issue a warning to add the property to configuration.
270227
:::
271228
272229
#### [Dispatch Namespaces](/cloudflare-for-platforms/workers-for-platforms/get-started/developing-with-wrangler/):
273230
274-
Workers for Platforms users can configure `experimental_remote: true` in dispatch namespace binding definitions:
231+
Workers for Platforms users can configure `remote: true` in dispatch namespace binding definitions:
275232
276233
<WranglerConfig>
277234
```jsonc title="wrangler.jsonc"
@@ -280,7 +237,7 @@ Workers for Platforms users can configure `experimental_remote: true` in dispatc
280237
{
281238
"binding": "DISPATCH_NAMESPACE",
282239
"namespace": "testing",
283-
"experimental_remote":true
240+
"remote":true
284241
}
285242
]
286243
}
@@ -291,9 +248,9 @@ This allows you to run your [dynamic dispatch Worker](/cloudflare-for-platforms/
291248

292249
### Unsupported remote bindings
293250

294-
Certain bindings are not supported for remote connections during local development (`experimental_remote: true`). These will always use local simulations or local values.
251+
Certain bindings are not supported for remote connections (i.e. with `remote: true`) during local development. These will always use local simulations or local values.
295252

296-
If `experimental_remote: true` is specified in Wrangler configuration for any of the following unsupported binding types, Cloudflare **will issue an error**. See [all supported and unsupported bindings for remote bindings](/workers/development-testing/bindings-per-env/).
253+
If `remote: true` is specified in Wrangler configuration for any of the following unsupported binding types, Cloudflare **will issue an error**. See [all supported and unsupported bindings for remote bindings](/workers/development-testing/bindings-per-env/).
297254

298255
- [**Durable Objects**](/workers/wrangler/configuration/#durable-objects): Enabling remote connections for Durable Objects may be supported in the future, but currently will always run locally. However, using Durable Objects in combination with remote bindings is possible. Refer to [Using remote resources with Durable Objects and Workflows](#using-remote-resources-with-durable-objects-and-workflows) below.
299256

@@ -325,13 +282,12 @@ There are two recommended patterns for this:
325282

326283
- **Local Durable Objects/Workflows with remote bindings:**
327284

328-
When you enable remote bindings in your [Wrangler configuration](/workers/wrangler/configuration), your locally running Durable Objects and Workflows can access remote resources. This allows such bindings, although run locally, to interact with remote resources during local development.
285+
When you enable remote bindings in your [Wrangler configuration](/workers/wrangler/configuration), your locally running Durable Objects and Workflows can access remote resources. This allows such bindings, although run locally, to interact with remote resources during local development.
329286

330287
- **Accessing remote Durable Objects/Workflows via service bindings:**
331288

332-
To interact with remote Durable Object or Workflow instances, deploy a Worker that defines those. Then, in your local Worker, configure a remote [service binding](/workers/runtime-apis/bindings/service-bindings/) pointing to the deployed Worker.
333-
Your local Worker will be then able to interact with the remote deployed Worker, which in turn can communicate with the remote Durable Objects/Workflows. Using this method, you can create a communication channel via the remote service binding, effectively using the deployed Worker as a proxy interface to the remote bindings during local development.
334-
289+
To interact with remote Durable Object or Workflow instances, deploy a Worker that defines those. Then, in your local Worker, configure a remote [service binding](/workers/runtime-apis/bindings/service-bindings/) pointing to the deployed Worker.
290+
Your local Worker will be then able to interact with the remote deployed Worker, which in turn can communicate with the remote Durable Objects/Workflows. Using this method, you can create a communication channel via the remote service binding, effectively using the deployed Worker as a proxy interface to the remote bindings during local development.
335291

336292
### Important Considerations
337293

@@ -347,11 +303,11 @@ Wrangler provides programmatic utilities to help tooling authors support remote
347303

348304
**Key APIs include:**
349305

350-
- [`experimental_startRemoteProxySession`](#experimental_startRemoteProxySession): Starts a proxy session that allows interaction with remote bindings.
306+
- [`startRemoteProxySession`](#startRemoteProxySession): Starts a proxy session that allows interaction with remote bindings.
351307
- [`unstable_convertConfigBindingsToStartWorkerBindings`](#unstable_convertconfigbindingstostartworkerbindings): Utility for converting binding definitions.
352308
- [`experimental_maybeStartOrUpdateProxySession`](#experimental_maybestartorupdatemixedmodesession): Convenience function to easily start or update a proxy session.
353309

354-
#### `experimental_startRemoteProxySession`
310+
#### `startRemoteProxySession`
355311

356312
This function starts a proxy session for a given set of bindings. It accepts options to control session behavior, including an `auth` option with your Cloudflare account ID and API token for remote binding access.
357313

@@ -365,15 +321,15 @@ It returns an object with:
365321
#### `unstable_convertConfigBindingsToStartWorkerBindings`
366322

367323
The `unstable_readConfig` utility returns an `Unstable_Config` object which includes the definition of the bindings included in the configuration file. These bindings definitions
368-
are however not directly compatible with `experimental_startRemoteProxySession`. It can be quite convenient to however read the binding declarations with `unstable_readConfig` and then
369-
pass them to `experimental_startRemoteProxySession`, so for this wrangler exposes `unstable_convertConfigBindingsToStartWorkerBindings` which is a simple utility to convert
370-
the bindings in an `Unstable_Config` object into a structure that can be passed to `experimental_startRemoteProxySession`.
324+
are however not directly compatible with `startRemoteProxySession`. It can be quite convenient to however read the binding declarations with `unstable_readConfig` and then
325+
pass them to `startRemoteProxySession`, so for this wrangler exposes `unstable_convertConfigBindingsToStartWorkerBindings` which is a simple utility to convert
326+
the bindings in an `Unstable_Config` object into a structure that can be passed to `startRemoteProxySession`.
371327

372328
:::note
373-
This type conversion is temporary. In the future, the types will be unified so you can pass the config object directly to `experimental_startRemoteProxySession`.
329+
This type conversion is temporary. In the future, the types will be unified so you can pass the config object directly to `startRemoteProxySession`.
374330
:::
375331

376-
#### `experimental_maybeStartOrUpdateRemoteProxySession`
332+
#### `maybeStartOrUpdateRemoteProxySession`
377333

378334
This wrapper simplifies proxy session management. It takes:
379335

@@ -391,32 +347,36 @@ The function:
391347
- If there are no remote bindings to be used (nor a pre-existing proxy session) it returns null, signaling that no proxy session is needed.
392348
- If the details of an existing proxy session have been provided it updates the proxy session accordingly.
393349
- Otherwise if starts a new proxy session.
394-
- Returns the proxy session details (that can later be passed as the second argument to `experimental_maybeStartOrUpdateRemoteProxySession`).
350+
- Returns the proxy session details (that can later be passed as the second argument to `maybeStartOrUpdateRemoteProxySession`).
395351

396352
#### Example
397353

398-
Here's a basic example of using Miniflare with `experimental_maybeStartOrUpdateRemoteProxySession` to provide a local dev session with remote bindings. This example uses a single hardcoded KV binding.
354+
Here's a basic example of using Miniflare with `maybeStartOrUpdateRemoteProxySession` to provide a local dev session with remote bindings. This example uses a single hardcoded KV binding.
399355

400356
<TypeScriptExample>
357+
401358
```ts
402359
import { Miniflare, MiniflareOptions } from "miniflare";
403-
import { experimental_maybeStartOrUpdateRemoteProxySession } from "wrangler";
360+
import { maybeStartOrUpdateRemoteProxySession } from "wrangler";
404361

405362
let mf: Miniflare | null;
406363

407-
let remoteProxySessionDetails: Awaited<ReturnType<typeof experimental_maybeStartOrUpdateRemoteProxySession>> | null = null;
364+
let remoteProxySessionDetails: Awaited<
365+
ReturnType<typeof maybeStartOrUpdateRemoteProxySession>
366+
> | null = null;
408367

409368
async function startOrUpdateDevSession() {
410-
remoteProxySessionDetails = await experimental_maybeStartOrUpdateRemoteProxySession({
411-
bindings: {
369+
remoteProxySessionDetails = await maybeStartOrUpdateRemoteProxySession(
370+
{
371+
bindings: {
412372
MY_KV: {
413-
type: 'kv_namespace',
414-
id: 'kv-id',
415-
experimental_remote: true,
416-
}
417-
}
373+
type: "kv_namespace",
374+
id: "kv-id",
375+
remote: true,
376+
},
377+
},
418378
},
419-
remoteProxySessionDetails
379+
remoteProxySessionDetails,
420380
);
421381

422382
const miniflareOptions: MiniflareOptions = {
@@ -425,7 +385,7 @@ async function startOrUpdateDevSession() {
425385
MY_KV: {
426386
id: "kv-id",
427387
remoteProxyConnectionString:
428-
remoteProxySessionDetails?.session.remoteProxyConnectionString,
388+
remoteProxySessionDetails?.session.remoteProxyConnectionString,
429389
},
430390
},
431391
};
@@ -441,10 +401,9 @@ async function startOrUpdateDevSession() {
441401

442402
// ... once the dev session is no longer needed run
443403
// `remoteProxySessionDetails?.session.dispose()`
444-
445404
```
446-
</TypeScriptExample>
447405

406+
</TypeScriptExample>
448407

449408
## `wrangler dev --remote` (Legacy)
450409

@@ -468,4 +427,3 @@ When using remote development, all bindings automatically connect to their remot
468427
### Limitations
469428

470429
- When you run a remote development session using the `--remote` flag, a limit of 50 [routes](/workers/configuration/routing/routes/) per zone is enforced. Learn more in[ Workers platform limits](/workers/platform/limits/#number-of-routes-per-zone-when-using-wrangler-dev---remote).
471-

0 commit comments

Comments
 (0)