Skip to content

Commit acd04e1

Browse files
docs: websockets do not work with vite dev server pre-Deno 2.8 and Fresh 2.4 (#3822)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
1 parent d738f22 commit acd04e1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

docs/latest/advanced/websockets.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ 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+
> [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.
14+
>
15+
> If you're stuck on an older Deno or Fresh, exercise WebSocket endpoints with a
16+
> production-style build instead:
17+
>
18+
> ```sh
19+
> deno task build && deno task start
20+
> ```
21+
>
22+
> This runs `deno serve` directly, so `Deno.upgradeWebSocket()` works as
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.
26+
927
## Quick start with `app.ws()`
1028
1129
The simplest way to add a WebSocket endpoint:

0 commit comments

Comments
 (0)