Skip to content

WebSocket functionality broken #38

Open
@xanedesu

Description

@xanedesu

What version of Elysia is running?

1.2.25

What version of Node Adapter are you using?

1.2.6

What platform is your computer?

Darwin 24.3.0 arm64 arm

What steps can reproduce the bug?

Create an Elysia app that handles WebSocket connections.

import { node } from "@elysiajs/node";
import { Elysia, t } from "elysia";

new Elysia({ adapter: node() })
  .ws("/ws", {
    open(ws) {
      console.log("Client connected", ws.data.query.token);
      ws.send({
        message: "Hello from Elysia!",
        time: Date.now(),
      });
    },
    close() {
      console.log("Client disconnected");
    },
    message(ws, buffer) {
      console.log("Message from client:", buffer);
      ws.send({
        token: ws.data.query.token,
        buffer,
        time: Date.now(),
      });
    },
    query: t.Object({
      token: t.String({
        minLength: 1,
      }),
    }),
    body: t.Uint8Array(),
  })
  .listen(3000, ({ hostname, port }) => {
    console.log(`🦊 Elysia is running at ${hostname}:${port}`);
  });

What is the expected behavior?

WebSocket connections should be successfully established and handled by the server.

What do you see instead?

WebSocket connections do not work. When I try to connect to the server, I receive a 404 status code.

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

Yes

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