Skip to content

Commit 70f8e62

Browse files
committed
docs: reflect that WS works in Vite dev on Fresh 2.4+ / Deno 2.8+
1 parent a1d530d commit 70f8e62

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

docs/latest/advanced/websockets.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ description: |
66
Fresh provides built-in helpers for upgrading HTTP connections to WebSockets.
77
There are two main approaches depending on your use case.
88

9-
> [warn]: WebSocket upgrades do not work under the Vite dev server (`deno task
10-
> dev`). Both `app.ws()` and `ctx.upgrade()` rely on `Deno.upgradeWebSocket()`,
11-
> which requires Deno's native HTTP server to be handling the request. Vite
12-
> serves requests through a Node HTTP server and forwards them to Fresh as
13-
> synthesized `Request` objects, so the 101 upgrade response cannot be
14-
> completed and the `open` handler is never invoked.
9+
> [info]: WebSocket upgrades under the Vite dev server (`deno task dev`) require
10+
> **Fresh 2.4+** and **Deno 2.8+**. On older versions `Deno.upgradeWebSocket()`
11+
> cannot complete the 101 handshake for requests Vite forwards from its Node
12+
> HTTP server, so `ctx.upgrade()` and `app.ws()` silently hang and the `open`
13+
> handler is never invoked.
1514
>
16-
> To test WebSocket endpoints locally, run a production-style build:
15+
> If you're stuck on an older Deno or Fresh, exercise WebSocket endpoints with a
16+
> production-style build instead:
1717
>
1818
> ```sh
1919
> deno task build && deno task start
2020
> ```
2121
>
2222
> This runs `deno serve` directly, so `Deno.upgradeWebSocket()` works as
23-
> expected. If you need WebSockets during iterative development, run a
24-
> separate Deno entry point (e.g. `deno serve -A main.ts`) alongside Vite, or
25-
> host the WebSocket server as a sidecar on its own port.
23+
> expected. Alternatively, run a separate Deno entry point (e.g.
24+
> `deno serve -A main.ts`) alongside Vite, or host the WebSocket server as a
25+
> sidecar on its own port.
2626
2727
## Quick start with `app.ws()`
2828

0 commit comments

Comments
 (0)