elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
10.6k stars 226 forks source link

app.server.port is not same app.listen(port) #917

Open baramofme opened 1 week ago

baramofme commented 1 week ago

What version of Elysia is running?

1.1.24

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

set port with app.listen method. and then, the print app.server.port variable

What is the expected behavior?

The app.server.port value should match the port number specified in the app.listen method

const app = new Elysia()
.listen(3002);

What do you see instead?

always same 3000

$ bun run --watch src/index.ts
🦊 Elysia is running at localhost:3002
Started server http://localhost:3000

Additional information

because of this bug, I cannot run another server using port 3000.

I am unable to start another server using port 3000 at the same time as elysiajs. It seems that elysia is turning on faster and blocking port 3000.

If you think about it, if you position the elysiajs startup order behind another server that uses 3000 ports, it will work.

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

yes, I did it.

crishoj commented 1 week ago

Tried to reproduce:

import Elysia from 'elysia'

const app = new Elysia()
    .listen(3002);

console.log('app.server.port =', app.server.port)

Output:

app.server.port = 3002

If you could post a minimal code example to reproduce the issue, it would be helpful.