Skip to content

Usage of ...rest in endpoint handlers causes Cannot read private member #state from an object whose class did not declare it #42

@fapspirit

Description

@fapspirit

What version of Elysia is running?

1.3.5

What version of Node Adapter are you using?

1.3.0

What platform is your computer?

Darwin 24.5.0 arm64 arm

What steps can reproduce the bug?

Create a basic app in test.ts file:

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

new Elysia({ adapter: node() })
    .get("/", (...context) => {
        console.log("Request received", ...context);
        return "Hello Elysia";
    })
    .listen(3000, ({ hostname, port }) => {
        console.log(`Elysia is running at http://${hostname}:${port}`);
    });

Run it with node:

node test.ts

Make a request to server:

curl localhost:3000/

What is the expected behavior?

  1. There is a log entry with "Request received" and list of arguments in the console
  2. Server response Hello Elysia string

What do you see instead?

  1. No server logs in console
  2. Server response with the following string:
Cannot read private member #state from an object whose class did not declare it%

Additional information

If I remove spread of arguments (...args in handler of / route), everything works.

Everything works correctly when running with Bun.

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