Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 2 additions & 3 deletions src/content/docs/durable-objects/platform/known-issues.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
pcx_content_type: concept
title: Known issues

---

import { GlossaryTooltip } from "~/components";
import { GlossaryTooltip, Steps } from "~/components";

Durable Objects is generally available. However, there are some known issues.

Expand Down Expand Up @@ -36,4 +35,4 @@ The Workers editor in the [Cloudflare dashboard](https://dash.cloudflare.com/) a

Currently, when developing locally (using `npx wrangler dev`), Durable Object [alarm methods](/durable-objects/api/alarms) may fail after a hot reload (if you edit the code while the code is running locally).

To avoid this issue, when using Durable Object alarms, close and restart your `wrangler dev` command after editing your code.
To avoid this issue, when using Durable Object alarms, close and restart your `wrangler dev` command after editing your code.
84 changes: 62 additions & 22 deletions src/content/docs/workers/wrangler/api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ description: A set of programmatic APIs that can be integrated with local
Cloudflare Workers-related workflows.
---

import { Render, TabItem, Tabs, Type, MetaInfo, WranglerConfig } from "~/components";
import {
Render,
TabItem,
Tabs,
Type,
MetaInfo,
WranglerConfig,
PackageManagers,
} from "~/components";

Wrangler offers APIs to programmatically interact with your Cloudflare Workers.

Expand Down Expand Up @@ -360,27 +368,6 @@ The bindings supported by `getPlatformProxy` are:

- [KV namespace bindings](/kv/api/)

- [Durable Object bindings](/durable-objects/api/)

- To use a Durable Object binding with `getPlatformProxy`, always [specify a `script_name`](/workers/wrangler/configuration/#durable-objects) and have the target Worker run in a separate terminal via [`wrangler dev`](/workers/wrangler/commands/#dev).

For example, you might have the following file read by `getPlatformProxy`.

<WranglerConfig>

```toml
[[durable_objects.bindings]]
name = "MyDurableObject"
class_name = "MyDurableObject"
script_name = "my-worker"
```

</WranglerConfig>

In order for this binding to be successfully proxied by `getPlatformProxy`, a worker named `my-worker`
with a Durable Object declaration using the same `class_name` of `"MyDurableObject"` must be run
separately via `wrangler dev`.

- [R2 bucket bindings](/r2/api/workers/workers-api-reference/)

- [Queue bindings](/queues/configuration/javascript-apis/)
Expand All @@ -399,3 +386,56 @@ The bindings supported by `getPlatformProxy` are:
- [Workers AI bindings](/workers-ai/get-started/workers-wrangler/#2-connect-your-worker-to-workers-ai)

<Render file="ai-local-usage-charges" product="workers" />

- <a name="durable-objects"></a>[Durable Object bindings](/durable-objects/api/)

- To use a Durable Object binding with `getPlatformProxy`, always specify a [`script_name`](/workers/wrangler/configuration/#durable-objects).

For example, you might have the following binding in a file read by `getPlatformProxy`.

<WranglerConfig>

```toml
[[durable_objects.bindings]]
name = "MyDurableObject"
class_name = "MyDurableObject"
script_name = "external-do-worker"
```

</WranglerConfig>

You will need to declare your Durable Object `"MyDurableObject"` in another Worker, called `external-do-worker` in this example.

```ts title="./external-do-worker/src/index.ts"
export class MyDurableObject extends DurableObject {
// Your DO code goes here
}

export default {
fetch() {
// Doesn't have to do anything, but a DO cannot be the default export
return new Response("Hello, world!");
},
};
```
That Worker also needs a Wrangler config that looks like this:

<WranglerConfig>
```json
{
"name": "external-do-worker",
"main": "src/index.ts",
"compatibility_date": "XXXX-XX-XX"
}
```
</WranglerConfig>

If you are not using RPC with your Durable Object, you can run a separate Wrangler dev session alongside your framework development server.

Otherwise, you can build your application and run both Workers in the same Wrangler dev session.

If you are using Pages:
<PackageManagers type="exec" pkg="wrangler" args="pages dev -c path/to/pages/wrangler.jsonc -c path/to/external-do-worker/wrangler.jsonc" />

If you are using Workers with Assets:
<PackageManagers type="exec" pkg="wrangler" args="dev -c path/to/workers-assets/wrangler.jsonc -c path/to/external-do-worker/wrangler.jsonc" />
Loading