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>
This commit is contained in:
William Weiss
2026-05-27 07:46:33 +02:00
committed by GitHub
co-authored by Bartek Iwańczuk
parent d738f22e02
commit acd04e13f8
+18
View File
@@ -6,6 +6,24 @@ description: |
Fresh provides built-in helpers for upgrading HTTP connections to WebSockets.
There are two main approaches depending on your use case.
> [info]: WebSocket upgrades under the Vite dev server (`deno task dev`) require
> **Fresh 2.4+** and **Deno 2.8+**. On older versions `Deno.upgradeWebSocket()`
> cannot complete the 101 handshake for requests Vite forwards from its Node
> HTTP server, so `ctx.upgrade()` and `app.ws()` silently hang and the `open`
> handler is never invoked.
>
> If you're stuck on an older Deno or Fresh, exercise WebSocket endpoints with a
> production-style build instead:
>
> ```sh
> deno task build && deno task start
> ```
>
> This runs `deno serve` directly, so `Deno.upgradeWebSocket()` works as
> expected. Alternatively, run a separate Deno entry point (e.g.
> `deno serve -A main.ts`) alongside Vite, or host the WebSocket server as a
> sidecar on its own port.
## Quick start with `app.ws()`
The simplest way to add a WebSocket endpoint: