From acd04e13f8033fa5cef86de5509001b4a997727e Mon Sep 17 00:00:00 2001 From: William Weiss Date: Wed, 27 May 2026 01:46:33 -0400 Subject: [PATCH] docs: websockets do not work with vite dev server pre-Deno 2.8 and Fresh 2.4 (#3822) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartek IwaƄczuk --- docs/latest/advanced/websockets.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/latest/advanced/websockets.md b/docs/latest/advanced/websockets.md index cac0bc85..9ddb1499 100644 --- a/docs/latest/advanced/websockets.md +++ b/docs/latest/advanced/websockets.md @@ -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: