1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-18 13:22:55 -05:00

test(ext/node): fix flaky node/http2.createServer() test (#27208)

This commit is contained in:
Yoshiya Hinosawa 2024-12-06 00:25:16 +09:00 committed by GitHub
parent ae5c743f33
commit 3bae68eda6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -152,6 +152,7 @@ Deno.test("[node/http2.createServer()]", {
// TODO(satyarohith): enable the test on windows.
ignore: Deno.build.os === "windows",
}, async () => {
const serverListening = Promise.withResolvers<number>();
const server = http2.createServer((_req, res) => {
res.setHeader("Content-Type", "text/html");
res.setHeader("X-Foo", "bar");
@ -159,8 +160,10 @@ Deno.test("[node/http2.createServer()]", {
res.write("Hello, World!");
res.end();
});
server.listen(0);
const port = (server.address() as net.AddressInfo).port;
server.listen(0, () => {
serverListening.resolve((server.address() as net.AddressInfo).port);
});
const port = await serverListening.promise;
const endpoint = `http://localhost:${port}`;
const response = await curlRequest([