mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 08:33:43 -05:00
fix(ext/http): Deno.Server should not be thenable (#20723)
Otherwise you can not return `Deno.Server` from async functions. Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com> Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
35f028daf2
commit
ae81065c75
2 changed files with 11 additions and 6 deletions
|
@ -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",
|
||||
|
|
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue