Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Do we have plan to support unix domain socket with Deno.serve? #20369

Closed
kt3k opened this issue Sep 4, 2023 · 5 comments · Fixed by #20759
Closed

Question: Do we have plan to support unix domain socket with Deno.serve? #20369

kt3k opened this issue Sep 4, 2023 · 5 comments · Fixed by #20759

Comments

@kt3k
Copy link
Member

kt3k commented Sep 4, 2023

If we support unix domain socket transport with Deno.serve, we probably can deprecate the entire std/http/server.ts. Do we have a plan for it?

@kt3k
Copy link
Member Author

kt3k commented Sep 7, 2023

Bun seems to have added unix domain socket support to Bun.serve in v0.8.1 https://bun.sh/blog/bun-v0.8.1#start-an-http-server-on-a-unix-domain-socket-with-bun-serve

@bartlomieju
Copy link
Member

From what I can tell there are technical roadblocks to support it. @mmastrac any objections?

@aapoalas
Copy link
Collaborator

aapoalas commented Sep 7, 2023

Node also supports serving through Unix socket and this is something I've been meaning to take into use on a particular project elsewhere the moment it becomes possible for that project.

From that point of view, I am personally of the opinion that a Unix socket should be a valid connection option for any HTTP server we have.

@mmastrac
Copy link
Contributor

mmastrac commented Sep 7, 2023

No objections. I suspect it should be pretty straightforward to implement as the Unix socket is plumbed through on the rust side. It just needs some JS support IIRC

@mmastrac
Copy link
Contributor

@kt3k I believe that this should be implementable like so:

  1. Add a Deno.ServeUnixOptions with a path property as a third overload to Deno.serve. ServeUnixOptions will need onListen and onError.

  2. If path is present on the options bag, we set a flag wantsUnix:

  const wantsHttps = options.cert || options.key;
  const wantsUnix = "path" in options;
  1. If wantsUnix is true, we configure listenOpts to be a unix listener.

  2. options.onListen and the default listener message need to be updated to handle the unix listener case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants