bun icon indicating copy to clipboard operation
bun copied to clipboard

node:http.ServerResponse.assignSocket is not implemented

Open pasha-vuiko opened this issue 1 year ago • 1 comments

What version of Bun is running?

0.5.9

What platform is your computer?

Darwin 22.4.0 arm64 arm

What steps can reproduce the bug?

node:http.ServerResponse.assignSocket is not implemented.

I was trying to write adapter for Fastify for native Bun http server. I was trying to implement it with fastify.inject() like this:

import {fastify} from "fastify";

const fastifyServer = fastify();

fastifyServer.get("/", async (request, reply) => {
  return {
    hello: "world",
  };
});

await fastifyServer.ready();

Bun.serve({
  port: 3000,
  async fetch(request) {
    let response = await fastifyServer.inject({
      method: request.method,
      url: request.url,
      payload: request.body,
      headers: request.headers,
    });

    return new Response(response.body, {
      headers: response.headers,
      status: response.statusCode,
      statusText: response.statusMessage,
    });
 
  },
});

So the problem is that fastify.inject() uses http.ServerResponse.assignSocket and bunch of other unimplemented Node.js http server stuff. I think it would be nice to have the ability to implement adapter like this, as possibly we can get ability to use Fastify with native Bun's http server

What is the expected behavior?

node:http.ServerResponse.assignSocket should be implemented

What do you see instead?

No response

Additional information

No response

pasha-vuiko avatar Apr 18 '23 18:04 pasha-vuiko

Newest issue: #6667

622 | }
623 | var OriginalWriteHeadFn, OriginalImplicitHeadFn;
624 | 
625 | class ServerResponse extends Writable {
626 | 
627 |   constructor(c) {
                             ^
TypeError: Cannot call a class constructor without |new|
      at ServerResponse (node:http:627:26)
      at new Response (example/node_modules/light-my-request/lib/response.js:10:2)

Electroid avatar Oct 26 '23 00:10 Electroid