oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
71.73k stars 2.55k forks source link

http.Server.listen(undefined) uses 3000 #12182

Open adraffy opened 4 days ago

adraffy commented 4 days ago

What version of Bun is running?

1.1.12

What platform is your computer?

Darwin 23.1.0 x86_64 i386

What steps can reproduce the bug?

import {createServer} from 'http';
let h = createServer(() => {});
h.listen(undefined, () => {
    console.log(h.address());
});

What is the expected behavior?

random open port

What do you see instead?

port 3000

Additional information

No response

paperdave commented 4 days ago

location of bug: src/js/node/http.ts line 529. node:http uses bun.serve and it defaults to port 3000 instead of random.

image