Skip to content

Commit d02f8a6

Browse files
Update src/content/docs/durable-objects/best-practices/websockets.mdx
Co-authored-by: Lambros Petrou <[email protected]>
1 parent 5cb8360 commit d02f8a6

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
@@ -28,7 +28,7 @@ In addition to [the Web Standard WebSocket API](/workers/runtime-apis/websockets
2828

2929
### How does Durable Object Hibernation work with WebSockets?
3030

31-
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-initialized, its `constructor` function is called, and it can access the WebSocket clients with the `this.ctx.getWebSockets()` function.
31+
When a Durable Object receives no events (like alarms) or messages for 10 seconds, the Durable Object is evicted from memory to avoid unnecessary charges. The WebSocket clients remain connected to the Cloudflare network. When your Durable Object receives an event during hibernation, it is re-initialized, its `constructor` function is called, and it can access the WebSocket clients with the `this.ctx.getWebSockets()` function.
3232

3333
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

0 commit comments

Comments
 (0)