Skip to content

Commit 61672ca

Browse files
Oxyjunpedrosousa
andauthored
Accepting PCX Review part 1
Co-authored-by: Pedro Sousa <[email protected]>
1 parent d9efb1d commit 61672ca

File tree

10 files changed

+23
-22
lines changed

10 files changed

+23
-22
lines changed

src/content/changelog/durable-objects/2025-04-07-durable-objects-free-tier.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ products:
77
date: 2025-04-07T06:00:00Z
88
---
99

10-
Durable Objects can now be used with zero commitment on the [Workers Free plan](/workers/platform/pricing/) allowing you to build AI agents with [Agents SDK](/agents), collaboration tools, and real-time applications like chat or multiplayer games.
10+
Durable Objects can now be used with zero commitment on the [Workers Free plan](/workers/platform/pricing/) allowing you to build AI agents with [Agents SDK](/agents/), collaboration tools, and real-time applications like chat or multiplayer games.
1111

1212
Durable Objects let you build stateful, serverless applications with millions of tiny coordination instances that run your application code alongside (in the same thread!) your durable storage. Each Durable Object can access its own SQLite database through a [Storage API](/durable-objects/best-practices/access-durable-objects-storage/). A Durable Object class is defined in a Worker script encapsulating the Durable Object's behavior when accessed from a Worker. To try the code below, click the button:
1313

src/content/changelog/durable-objects/2025-04-07-sqlite-in-durable-objects-ga.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: SQLite in Durable Objects GA
3-
description: SQLite-bakced Durable Objects are generally available.
3+
description: SQLite-backed Durable Objects are generally available.
44
products:
55
- durable-objects
66
- workers
@@ -9,7 +9,7 @@ date: 2025-04-07T06:00:00Z
99

1010
SQLite in Durable Objects is now generally available (GA). Since the [public beta](https://blog.cloudflare.com/sqlite-in-durable-objects/) in September 2024, we've added feature parity and robustness for the SQLite storage backend compared to the preexisting key-value (KV) storage backend for Durable Objects.
1111

12-
SQLite-backed Durable Objects are recommended for all new Durable Object classes, using `new_sqlite_classes` [Wrangler configuration](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class). Only SQLite-backed Durable Objects have access to Storage API's [SQL](/durable-objects/api/storage-api/#sql-api) and [point-in-time recovery](/durable-objects/api/storage-api/#pitr-point-in-time-recovery-api) methods, which provide relational data modelling, SQL querying, and better data management.
12+
SQLite-backed Durable Objects are recommended for all new Durable Object classes, using `new_sqlite_classes` [Wrangler configuration](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class). Only SQLite-backed Durable Objects have access to Storage API's [SQL](/durable-objects/api/storage-api/#sql-api) and [point-in-time recovery](/durable-objects/api/storage-api/#pitr-point-in-time-recovery-api) methods, which provide relational data modeling, SQL querying, and better data management.
1313

1414
```js
1515
export class MyDurableObject extends DurableObject {
@@ -21,7 +21,7 @@ export class MyDurableObject extends DurableObject {
2121

2222
async sayHello() {
2323
let result = this.sql
24-
.exec("SELECT 'Hello, World!' as greeting")
24+
.exec("SELECT 'Hello, World!' AS greeting")
2525
.one();
2626
return result.greeting;
2727
}

src/content/docs/durable-objects/api/storage-api.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ export class Counter extends DurableObject {
6767
```
6868
</TypeScriptExample>
6969

70-
JavaScript is a single-threaded and event-driven programming language. This means that JavaScript runtimes, by default, allow requests to interleave with each other which can lead to concurrency bugs. The Durable Objects runtime uses a combination of <GlossaryTooltip term="input gate">input gates</GlossaryTooltip> and <GlossaryTooltip term="output gate">output gates</GlossaryTooltip> to avoid this type of concurrency bug when performing storage operations. Learn more with our [blog post](https://blog.cloudflare.com/durable-objects-easy-fast-correct-choose-three/)
70+
JavaScript is a single-threaded and event-driven programming language. This means that JavaScript runtimes, by default, allow requests to interleave with each other which can lead to concurrency bugs. The Durable Objects runtime uses a combination of <GlossaryTooltip term="input gate">input gates</GlossaryTooltip> and <GlossaryTooltip term="output gate">output gates</GlossaryTooltip> to avoid this type of concurrency bug when performing storage operations. Learn more in our [blog post](https://blog.cloudflare.com/durable-objects-easy-fast-correct-choose-three/).
7171

7272
## SQL API
7373

74-
The `SqlStorage` interface encapsulates methods that modify the SQLite database embedded within a Durable Object. The `SqlStorage` interface is accessible via the [`sql` property](/durable-objects/api/storage-api/#) of `DurableObjectStorage` class.
74+
The `SqlStorage` interface encapsulates methods that modify the SQLite database embedded within a Durable Object. The `SqlStorage` interface is accessible via the [`sql` property](/durable-objects/api/storage-api/#sql) of `DurableObjectStorage` class.
7575

7676
For example, using `sql.exec()`, a user can create a table, then insert rows into the table.
7777

@@ -141,7 +141,7 @@ if (!rawResult.done) {
141141
console.log(cursor.toArray()); // prints [{ artistid: 456, artistname: 'Bob' },{ artistid: 789, artistname: 'Charlie' }]
142142
```
143143

144-
`SqlStorageCursor` had the following properties:
144+
`SqlStorageCursor` has the following properties:
145145

146146
* `columnNames`: <Type text='string[]' />
147147
* The column names of the query in the order they appear in each row array returned by the `raw` iterator.
@@ -186,7 +186,7 @@ let size = ctx.storage.sql.databaseSize;
186186

187187
For [SQLite-backed Durable Objects](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class), the following point-in-time-recovery (PITR) API methods are available to restore a Durable Object's embedded SQLite database to any point in time in the past 30 days. These methods apply to the entire SQLite database contents, including both the object's stored SQL data and stored key-value data using the key-value `put()` API. The PITR API is not supported in local development because a durable log of data changes is not stored locally.
188188

189-
The PITR API represents points in times using 'bookmarks'. A bookmark is a mostly alphanumeric string like `0000007b-0000b26e-00001538-0c3e87bb37b3db5cc52eedb93cd3b96b`. Bookmarks are designed to be lexically comparable: a bookmark representing an earlier point in time compares less than one representing a later point, using regular string comparison.
189+
The PITR API represents points in time using 'bookmarks'. A bookmark is a mostly alphanumeric string like `0000007b-0000b26e-00001538-0c3e87bb37b3db5cc52eedb93cd3b96b`. Bookmarks are designed to be lexically comparable: a bookmark representing an earlier point in time compares less than one representing a later point, using regular string comparison.
190190

191191
### `getCurrentBookmark`
192192

@@ -377,7 +377,7 @@ The `put()` method returns a `Promise`, but most applications can discard this p
377377
- For Durable Objects with a key-value storage backend, an in-progress `deleteAll()` operation can fail, which may leave a subset of data undeleted. Durable Objects with a SQLite storage backend do not have a partial `deleteAll()` issue because `deleteAll()` operations are atomic (all or nothing).
378378
- `deleteAll()` does not proactively delete [alarms](/durable-objects/api/alarms/). Use [`deleteAlarm()`](/durable-objects/api/alarms/#deletealarm) to delete an alarm.
379379

380-
### `transaction`
380+
### `transaction`
381381

382382
- `transaction(closureFunction(txn))`: <Type text='Promise' />
383383

@@ -389,7 +389,7 @@ The `put()` method returns a `Promise`, but most applications can discard this p
389389

390390
- Provides access to the `put()`, `get()`, `delete()` and `list()` methods documented above to run in the current transaction context. In order to get transactional behavior within a transaction closure, you must call the methods on the `txn` Object instead of on the top-level `ctx.storage` Object.<br/><br/>Also supports a `rollback()` function that ensures any changes made during the transaction will be rolled back rather than committed. After `rollback()` is called, any subsequent operations on the `txn` Object will fail with an exception. `rollback()` takes no parameters and returns nothing to the caller.
391391

392-
* When using [the SQLite-backed storage engine](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend), the `txn` object is obsolete. Any storage operations performed directly on the `ctx.storage` object, including SQL queries using [`ctx.storage.sql.exec()`](/durable-objects/api/storage-api/#exec), will be considered part of the transaction.
392+
- When using [the SQLite-backed storage engine](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend), the `txn` object is obsolete. Any storage operations performed directly on the `ctx.storage` object, including SQL queries using [`ctx.storage.sql.exec()`](/durable-objects/api/storage-api/#exec), will be considered part of the transaction.
393393

394394
### `sync`
395395

src/content/docs/durable-objects/best-practices/access-durable-objects-storage.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A Durable Object's [in-memory state](/durable-objects/reference/in-memory-state/
1515
## Access storage
1616

1717
:::note[Recommended SQLite-backed Durable Objects]
18-
We recommend all new Durable Object classes use the [SQLite storage backend](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class).
18+
Cloudflare recommends all new Durable Object classes use the [SQLite storage backend](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class).
1919

2020
The [key-value storage backend](/durable-objects/reference/durable-objects-migrations/#create-durable-object-class-with-key-value-storage) remains for backwards compatibility, and a migration path from KV storage to SQLite storage for existing Durable Object classes will be available in the future.
2121
:::
@@ -118,10 +118,10 @@ type User = {
118118
}
119119
```
120120
121-
This type can then be passed as the type parameter to a `sql.exec` call:
121+
This type can then be passed as the type parameter to a `sql.exec()` call:
122122
123123
```ts
124-
// The type parameter is passed between the "pointy brackets" before the function argument:
124+
// The type parameter is passed between angle brackets before the function argument:
125125
const result = this.ctx.storage.sql.exec<User>("SELECT id, name, email_address, version FROM users WHERE id = ?", user_id).one()
126126
// result will now have a type of "User"
127127

@@ -147,7 +147,8 @@ for (let row of cursor) {
147147
}
148148
```
149149

150-
You can represent the shape of any result type you wish, including more complex types. If you are performing a JOIN across multiple tables, you can compose a type that reflects the results of your queries.
150+
You can represent the shape of any result type you wish, including more complex types. If you are performing a
151+
`JOIN` across multiple tables, you can compose a type that reflects the results of your queries.
151152

152153
## Indexes in SQLite
153154

src/content/docs/durable-objects/best-practices/websockets.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Tabs, TabItem, GlossaryTooltip, Type } from "~/components";
99

1010
This guide covers how to use Durable Objects as WebSocket servers that can connect thousands of clients (per instance), as well as a WebSocket client to connect to other servers or even Durable Objects.
1111

12-
There are two sets of WebSockets API
12+
There are two sets of WebSockets API:
1313

1414
1. Native Durable Object WebSocket API, which allows your Durable Object to hibernate without disconnecting clients when not actively doing work **(recommended)**.
1515
2. Web Standard WebSocket APIs, using the familiar `addEventListener` event pattern.

src/content/docs/durable-objects/platform/pricing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Durable Objects can incur two types of billing: compute and storage.
1818
These examples exclude the costs for the Workers calling the Durable Objects. When modelling the costs of a Durable Object, note that:
1919

2020
* Inactive objects receiving no requests do not incur any duration charges.
21-
* The [WebSocket Hibernation API](/durable-objects/best-practices/websockets#websocket-hibernation-api) can dramatically reduce duration-related charges for Durable Objects communicating with clients over the WebSocket protocol, especially if messages are only transmitted occasionally at sparse intervals.
21+
* The [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api) can dramatically reduce duration-related charges for Durable Objects communicating with clients over the WebSocket protocol, especially if messages are only transmitted occasionally at sparse intervals.
2222

2323
#### Example 1
2424

src/content/docs/durable-objects/reference/environments.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ durable_objects.bindings = [
6565

6666
Local development sessions create a standalone, local-only environment that mirrors the production environment, so that you can test your Worker and Durable Objects before you deploy to production.
6767

68-
An existing Durable Object binding of DB would be available to your Worker when running locally.
68+
An existing Durable Object binding of `DB` would be available to your Worker when running locally.
6969

7070
Refer to Workers [Local development](/workers/local-development/#supported-resource-bindings-in-different-environments).
7171

src/content/docs/durable-objects/what-are-durable-objects.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,6 @@ Finally, the following blog posts may help you learn some of the technical imple
108108

109109
## Get started
110110

111-
Get started now by following the ["Tutorial with SQL API"](/durable-objects/get-started/) to create your first application using Durable Objects.
111+
Get started now by following the ["Get started" guide](/durable-objects/get-started/) to create your first application using Durable Objects.
112112

113113
[^1]: Storage per Durable Object with SQLite is currently 1 GB. This will be raised to 10 GB for general availability.

src/content/partials/durable-objects/durable-objects-pricing.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ await durableObjectStub.cat(); // billed as a request
3535

3636
<sup>3</sup> Application level auto-response messages handled by [`state.setWebSocketAutoResponse()`](/durable-objects/best-practices/websockets/) will not incur additional wall-clock time, and so they will not be charged.
3737

38-
<sup>4</sup> Duration is billed in wall-clock time as long as the Object is active, but is shared across all requests active on an Object at once. Calling `accept()` on a WebSocket in an Object will incur duration charges for the entire time the WebSocket is connected. Note that the request context for a Durable Object extends for 10 seconds after the last client disconnects. The request context of a Durable Object is evaluated every 70 seconds and the context is ended if it has been active for 70 seconds. If you prefer, use the [WebSocket hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api) to avoid incurring duration charges once all event handlers finish running.
38+
<sup>4</sup> Duration is billed in wall-clock time as long as the Object is active, but is shared across all requests active on an Object at once. Calling `accept()` on a WebSocket in an Object will incur duration charges for the entire time the WebSocket is connected. Note that the request context for a Durable Object extends for 10 seconds after the last client disconnects. The request context of a Durable Object is evaluated every 70 seconds and the context is ended if it has been active for 70 seconds. If you prefer, use the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api) to avoid incurring duration charges once all event handlers finish running.
3939

4040
<sup>5</sup> Duration billing charges for the 128 MB of memory your Durable Object is allocated, regardless of actual usage. If your account creates many instances of a single Durable Object class, Durable Objects may run in the same isolate on the same physical machine and share the 128 MB of memory. These Durable Objects are still billed as if they are allocated a full 128 MB of memory.
4141

@@ -44,7 +44,7 @@ await durableObjectStub.cat(); // billed as a request
4444
{ props.product === "durable-objects" && <><AnchorHeading title="Storage billing" depth={2}/></> }
4545
{ props.product === "workers" && <><AnchorHeading title="Storage billing" depth={3}/></> }
4646

47-
The [Durable Objects Storage API](/durable-objects/api/storage-api) is only accessible from within Durable Objects. Pricing depends on the type of storage your Durable Objects use.
47+
The [Durable Objects Storage API](/durable-objects/api/storage-api/) is only accessible from within Durable Objects. Pricing depends on the type of storage your Durable Objects use.
4848

4949
- **SQLite-backed Durable Objects (recommended)**: This is the recommended storage for new Durable Object classes. Workers Free plan can only create and access SQLite-backed Durable Objects.
5050
- **Key-value storage backed Durable Objects**: This is only available on the Workers Paid plan.
@@ -68,7 +68,7 @@ The [Durable Objects Storage API](/durable-objects/api/storage-api) is only acce
6868

6969
<sup>3</sup> Each `setAlarm` is billed as a single row written.
7070

71-
<sup>4</sup> Deletes are counted as rows_written.
71+
<sup>4</sup> Deletes are counted as rows written.
7272

7373
<sup>5</sup> Durable Objects will be billed for stored data until the data is removed. Once the data is removed, the object will be cleaned up automatically by the system.
7474

src/content/partials/durable-objects/storage-intro-text.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The Durable Object Storage API comes with several methods, including [SQL API](/
1111

1212
Each method is implicitly wrapped inside a transaction, such that its results are atomic and isolated from all other storage operations, even when accessing multiple key-value pairs.
1313

14-
| Type of storage API | SQLite backed Durable Object | KV backed Durable Object |
14+
| Type of storage API | SQLite-backed Durable Object | KV-backed Durable Object |
1515
| ------------------- | ---------------------------- | ------------------------ |
1616
| SQL API |||
1717
| PITR API |||

0 commit comments

Comments
 (0)