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

fix(ext/http): Deno.Server should not be thenable #20723

Merged
merged 6 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cli/tests/unit/serve_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3717,6 +3717,17 @@ async function curlRequestWithStdErr(args: string[]) {
return [new TextDecoder().decode(stdout), new TextDecoder().decode(stderr)];
}

Deno.test("Deno.Server is not thenable", async () => {
// deno-lint-ignore require-await
async function serveTest() {
const server = Deno.serve({ port: servePort }, (_) => new Response(""));
assert(!("then" in server));
return server;
}
const server = await serveTest();
await server.shutdown();
});

Deno.test(
{
ignore: Deno.build.os === "windows",
Expand Down
6 changes: 0 additions & 6 deletions ext/http/00_serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { listen, listenOptionApiName, TcpConn } from "ext:deno_net/01_net.js";
import { listenTls } from "ext:deno_net/02_tls.js";
const {
ArrayPrototypePush,
Error,
ObjectHasOwn,
ObjectPrototypeIsPrototypeOf,
PromisePrototypeCatch,
Expand Down Expand Up @@ -700,11 +699,6 @@ function serveHttpOn(context, callback) {
context.closed = true;
}
},
then() {
throw new Error(
"Deno.serve no longer returns a promise. await server.finished instead of server.",
);
},
ref() {
ref = true;
if (currentPromise) {
Expand Down