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

BREAKING(http/server): deprecate serve and serveTls #3381

Merged
merged 16 commits into from
Jul 21, 2023

Conversation

lino-levan
Copy link
Contributor

@lino-levan lino-levan commented May 16, 2023

Closes #3338

Tasks:

@lino-levan lino-levan requested a review from kt3k as a code owner May 16, 2023 19:36
@kt3k
Copy link
Member

kt3k commented May 17, 2023

Thanks for the PR.

I think we also need to wait for Deploy to support Deno.serve before landing this

@kt3k kt3k changed the title breaking(http/server): deprecate serve and serveTls BREAKING(http/server): deprecate serve and serveTls Jul 5, 2023
@iuioiua
Copy link
Collaborator

iuioiua commented Jul 6, 2023

Perhaps, std/http/file_server.ts should also be adjusted to use Deno.serve() in this PR.

@github-actions github-actions bot added the http label Jul 6, 2023
@lino-levan
Copy link
Contributor Author

What version of std should this be removed by?

@lino-levan
Copy link
Contributor Author

lino-levan commented Jul 7, 2023

I found a few files that use serve or similar and I'm not sure if it makes sense for them to stick around:

  • http/bench.ts - seems like just a quick file to bench the http server, doesn't really make sense to stick around AFAIK
  • http/testdata/simple_https_server.ts - seems to have been used at one point in a test but no longer is referenced anywhere in the codebase. Also doesn't work right now at all since it imports something that doesn't exist.
  • http/testdata/simple_server.ts - seems to have been used at one point in a test but is no longer referenced anywhere in the codebase

Should these be removed? I've updated them to use Deno.serve for now.

@iuioiua
Copy link
Collaborator

iuioiua commented Jul 8, 2023

Should these be removed? I've updated them to use Deno.serve for now.

I think so. The points you've raised seem to justify removing them.

@kt3k
Copy link
Member

kt3k commented Jul 8, 2023

Should these be removed?

They look ok to remove to me too.

@lino-levan
Copy link
Contributor Author

lino-levan commented Jul 8, 2023

Deno.serve just landed in deploy. Should now be fine to merge after a review.

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

http/server.ts Outdated Show resolved Hide resolved
@iuioiua
Copy link
Collaborator

iuioiua commented Jul 11, 2023

There are snippets that contain the use of the std/http/server, which I think should be replaced with the use of Deno.serve(). E.g. https://deno.land/[email protected]/http/server_sent_event.ts

@github-actions github-actions bot added the json label Jul 12, 2023
@lino-levan
Copy link
Contributor Author

I'm wondering if we should also deprecate serveListener and the Server class?

@iuioiua
Copy link
Collaborator

iuioiua commented Jul 12, 2023

I think we should.

@kt3k
Copy link
Member

kt3k commented Jul 13, 2023

I'm wondering if we should also deprecate serveListener and the Server class?

I think that's another independent topic. The use case like serving HTTP over unix domain socket listener (Deno.listen({ path: "/foo/bar.sock", transport: "unix" })) is not covered by Deno.serve.

@lino-levan
Copy link
Contributor Author

I think that's another independent topic. The use case like serving HTTP over unix domain socket listener (Deno.listen({ path: "/foo/bar.sock", transport: "unix" })) is not covered by Deno.serve.

Ah, didn't know that. Reverting the deprecations.

@lino-levan
Copy link
Contributor Author

The trouble I'm having is that we should definitely remove some types before 1.0 and replace them with ones that make more sense. For instance

export interface ServeInit extends Partial<Deno.ListenOptions> {
  signal?: AbortSignal;
  onError?: (error: unknown) => Response | Promise<Response>;
  onListen?: (params: { hostname: string; port: number }) => void;
}

is used for serve and serveListener. With serve being dropped, this type will only matter for serveListener. serveListener uses the type as Omit<ServeInit, "port" | "hostname">. It doesn't make sense for this type to extend Deno.ListenOptions if the only reference to it in the future will specifically omit all of the types that Deno.ListenOptions provides.

@iuioiua
Copy link
Collaborator

iuioiua commented Jul 16, 2023

I think that's another independent topic. The use case like serving HTTP over unix domain socket listener (Deno.listen({ path: "/foo/bar.sock", transport: "unix" })) is not covered by Deno.serve.

According the API reference, Deno.listen() doesn't support UNIX sockets. Neither do serveListener() and Server. Is this right?

@kt3k
Copy link
Member

kt3k commented Jul 17, 2023

@iuioiua

According the API reference, Deno.listen() doesn't support UNIX sockets. Neither do serveListener() and Server. Is this right?

That should be visible with Show Unstable API checked

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM again

@lino-levan
Copy link
Contributor Author

I'm unsure if we should land this in it's current state with #3381 (comment) still remaining a question. Any thoughts?

@kt3k
Copy link
Member

kt3k commented Jul 19, 2023

Ah, ok. I missed that.

With serve being dropped, this type will only matter for serveListener. serveListener uses the type as Omit<ServeInit, "port" | "hostname">. It doesn't make sense for this type to extend Deno.ListenOptions if the only reference to it in the future will specifically omit all of the types that Deno.ListenOptions provides.

I think replacing Omit<ServeInit, "port" | "hostname"> with its own interface (such as ServeListenerOptions) with only necessary props copied from ServeInit makes more sense.

@lino-levan
Copy link
Contributor Author

I think replacing Omit<ServeInit, "port" | "hostname"> with its own interface (such as ServeListenerOptions) with only necessary props copied from ServeInit makes more sense.

Seems reasonable, going to update the PR.

@lino-levan
Copy link
Contributor Author

LGTM now.

kt3k added a commit to kt3k/file_server_check that referenced this pull request Jul 21, 2023
@kt3k
Copy link
Member

kt3k commented Jul 21, 2023

Tested this branch's version of file_server https://raw.githubusercontent.com/denoland/deno_std/b2a0642521f5323a9bd9e772fafc3f006ac7e936/http/file_server.ts on Deploy, and it seemed working https://small-hawk-66-j5jx0nq05yh0.deno.dev/

I think this is ready to land.

Thank you for your contribution!

@kt3k kt3k merged commit 1d489cf into denoland:main Jul 21, 2023
9 checks passed
@iuioiua iuioiua mentioned this pull request Jul 21, 2023
jlandowner added a commit to jlandowner/deno-docs that referenced this pull request Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Align serve, serveTls, and serveListener signatures with Deno.serve
3 participants