oven-sh / bun

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

`IncomingMessage#socket` not implemented #5331

Open zefir-git opened 1 year ago

zefir-git commented 1 year ago

What version of Bun is running?

1.0.1

What platform is your computer?

Linux 6.3.12-200.fc38.x86_64 x86_64 unknown and Linux 6.4.14-200.fc38.x86_64 x86_64 unknown

What steps can reproduce the bug?

http.createServer((request: http.IncomingMessage, response: http.ServerResponse) => {
    request.socket;
});

What is the expected behavior?

IncomingMessage#socket from node:http should be net.Socket

What do you see instead?

TS2339: Property socket does not exist on type IncomingMessage

Additional information

https://github.com/oven-sh/bun/blob/03d9bcd440bd74cf21f4ac9ec1919ad074077231/docs/runtime/nodejs-apis.md?plain=1#L59-L61

https://github.com/oven-sh/bun/blob/03d9bcd440bd74cf21f4ac9ec1919ad074077231/docs/runtime/nodejs-apis.md?plain=1#L79-L81

Documentation reports full http compatibility and nearly full net compatibility.

sirenkovladd commented 1 year ago

I think it's related to https://github.com/oven-sh/bun/issues/4360

nektro commented 4 months ago

does this still reproduce for you? it appears to be working on my end in Bun 1.1.9 (you may need to run bun upgrade)

import http from "node:http";

const server = http.createServer(
  (request: http.IncomingMessage, response: http.ServerResponse) => {
    console.log(request.socket);
    response.write("hello");
    response.end();
  }
);
server.listen(3000);
Jarred-Sumner commented 4 months ago

It’s not truly implemented. Some things will work but some other things will not. It might work fine for this surface though.