Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
Co-authored-by: Lambros Petrou <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent cfaa746 commit 327660b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/content/docs/durable-objects/api/state.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Tabs, TabItem } from "~/components";

The `DurableObjectState` interface is accessible as an instance property on the Durable Objects class. This interface encapsulates methods that modify the state of a Durable Object, for example which WebSockets are attached to a Durable Object instance or how the runtime should handle concurrent Durable Object requests.

The `DurableObjectState` interface is different that the [Storage API](/durable-objects/api/storage-api) in that it does not have top level methods which manipulate persistant application data. These methods are instead encapsulated in the [`DurableObjectStorage`](/durable-objects/api/storage-api) interface and accessed by [`DurableObjectState::storage`](/durable-objects/api/state/#storage).
The `DurableObjectState` interface is different from the [Storage API](/durable-objects/api/storage-api) in that it does not have top-level methods which manipulate persistent application data. These methods are instead encapsulated in the [`DurableObjectStorage`](/durable-objects/api/storage-api) interface and accessed by [`DurableObjectState::storage`](/durable-objects/api/state/#storage).

<Tabs> <TabItem label="JavaScript" icon="seti:javascript">

Expand Down Expand Up @@ -108,7 +108,7 @@ export class MyDurableObject extends DurableObject {

`acceptWebSocket` is part of the [WebSocket Hibernation API](durable-objects/reference/websockets/#websocket-hibernation), which allows a Durable Object instance to be removed from memory to save costs while keeping its WebSockets connected.

`acceptWebSocket` adds a WebSocket to the set of WebSockets attached to the Durable Object instance. Once called, any incoming messages will be delivered by calling the Durable Objects `webSocketMessage` handler, and `webSocketClose` will be invoked upon disconnect. After calling `acceptWebSocket`, the WebSocket is accepted and its `send` and `close` methods can be used.
`acceptWebSocket` adds a WebSocket to the set of WebSockets attached to the Durable Object instance. Once called, any incoming messages will be delivered by calling the Durable Object's `webSocketMessage` handler, and `webSocketClose` will be invoked upon disconnect. After calling `acceptWebSocket`, the WebSocket is accepted and its `send` and `close` methods can be used.

The [WebSocket Hibernation API](durable-objects/reference/websockets/#websocket-hibernation) takes the place of the standard [WebSockets API](/workers/runtime-apis/websockets/). Therefore, `ws.accept` must not have been called separately and `ws.addEventListener` method will not receive events as they will instead be delivered to the Durable Object.

Expand All @@ -131,7 +131,7 @@ The WebSocket Hibernation API permits a maximum of 32,768 WebSocket connections

:::note[`waitUntil` is not necessary]

Disconnected WebSockets are not returned by this method, but `getWebSockets` may still return websockets even after `ws.close` has been called. For example, if the server-side WebSocket sends a close, but does not receive one back (and has not detected a disconnect from the client), then the connection is in the CLOSING readyState. The client might send more messages, so the WebSocket is technically not disconnected.
Disconnected WebSockets are not returned by this method, but `getWebSockets` may still return websockets even after `ws.close` has been called. For example, if the server-side WebSocket sends a close, but does not receive one back (and has not detected a disconnect from the client), then the connection is in the CLOSING 'readyState'. The client might send more messages, so the WebSocket is technically not disconnected.

:::

Expand Down Expand Up @@ -237,7 +237,7 @@ If no parameter or a parameter of `0` is provided and a timeout has been previou

### `abort`

`abort` is used to forcibly reset a Durable Object instance. A JavaScript Error with the message passed as a parameter will be logged. This error is not able to be caught within the applciation code.
`abort` is used to forcibly reset a Durable Object instance. A JavaScript `Error` with the message passed as a parameter will be logged. This error is not able to be caught within the application code.

```js
// Durable Object
Expand Down

0 comments on commit 327660b

Please sign in to comment.