Skip to content

cloudflare_durable WebSockets broken in preview; cloudflare_module inconsistent on Workers #722

@Erafle

Description

@Erafle

Describe the bug

While implementing NuxtHub Realtime / WebSockets following the official guide:
https://hub.nuxt.com/docs/guides/realtime

I’m seeing two issues depending on the Nitro preset:

  1. cloudflare_durable preset: WebSocket connections never appear to establish after npm run build + npm run preview (visitor count stays at 0). In the browser console I also see:

WebSocket connection to 'ws://localhost:8787/ws/visitors' failed:

I get the same “0 visitors” behavior when deploying/running on Cloudflare Workers too.

  1. cloudflare_module preset: Works correctly in npm run build + npm run preview, but once deployed to Cloudflare Workers, visitor counts are inconsistent (e.g. sometimes shows 1 visitor with 2 tabs open, sometimes 2, sometimes fluctuates).

This started happening on the latest NuxtHub update (multi-vendo).

Steps to reproduce

Repro A — cloudflare_durable preset (fails in preview + Workers)

  1. Create a Nuxt app and install NuxtHub.
  2. Follow the Realtime guide.
  3. Configure Nitro preset to cloudflare_durable (as per docs / recommended approach).
  4. Run:
    • npm run build
    • npm run preview
  5. Open the app in two tabs.
  6. Observe the Realtime visitors counter stays at 0 (no connections).

(Also reproduced on Cloudflare Workers with the same preset: visitors stay at 0.)

Repro B — cloudflare_module preset (works in preview, inconsistent on Workers)

  1. Same setup as above, but set Nitro preset to cloudflare_module (Nitro docs).
  2. Run:
    • npm run build
    • npm run preview
  3. Open two tabs → visitors count behaves as expected locally.
  4. Deploy to Cloudflare Workers.
  5. Open two tabs → visitors count is inconsistent (often shows 1 even with 2 tabs, sometimes 2, sometimes fluctuates).

Expected behavior

  • With cloudflare_durable, after npm run build + npm run preview, WebSocket connections should work the same way as they do in dev, and the visitors count should increase when opening multiple tabs.
  • On Cloudflare Workers, visitors count should be stable and accurate for concurrent connections, regardless of preset.

Actual behavior

  • cloudflare_durable: no working websocket connections in preview (and also seems broken on Workers). Visitors stay at 0.
  • cloudflare_module: preview works, but Workers deployment yields inconsistent visitor counts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions