Skip to content

Commit a1d30d7

Browse files
authored
Update src/content/docs/durable-objects/best-practices/websockets.mdx
1 parent b9eaff0 commit a1d30d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ In addition to [the Web Standard WebSocket API](/workers/runtime-apis/websockets
3030

3131
When a Durable Object receives no events or messages for 10 seconds, the Durable Object is evicted from memory to avoid unnecessary usage. The WebSocket clients remain connected to the Cloudflare network. When your Durable Object receives an event during hibernation, it is re-instantiated, its `constructor` function is called, and it can access the WebSocket clients with the `this.ctx.getWebSockets()` function.
3232

33-
When the Durable Object is evicted from memory, it's in-memory state is reset. It is common to rely on in-memory state to organize your WebSockets (ex: keeping your WebSockets in rooms with a Map<WebSocket, Object> data type). With Hibernation, you must restore the in-memory state of your Durable Object within the `constructor` function.
33+
When the Durable Object is evicted from memory, its in-memory state is reset. It is common to rely on in-memory state to organize your WebSockets (for example, keeping your WebSockets in rooms with a `Map<WebSocket, Object>` data type). With Hibernation, you must restore the in-memory state of your Durable Object within the `constructor` function.
3434

3535
To do this, you can use the `serializeAttachment` to persist additional data with the Durable Object WebSocket class, which will persist the data to the Durable Object's storage. Upon re-initialization of the Durable Object, you can access this data with `deserializeAttachment`.
3636

0 commit comments

Comments
 (0)