mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 08:39:09 -05:00
test(ext/node): reduce http_test flakiness (#24742)
(cherry picked from commit 99e811f5eb
)
This commit is contained in:
parent
ea3251effd
commit
b5b9904285
1 changed files with 7 additions and 4 deletions
|
@ -1325,9 +1325,10 @@ Deno.test("[node/http] http.request() post streaming body works", async () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const deferred = Promise.withResolvers<void>();
|
const responseEnded = Promise.withResolvers<void>();
|
||||||
|
const fileClosed = Promise.withResolvers<void>();
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
deferred.reject(new Error("timeout"));
|
responseEnded.reject(new Error("timeout"));
|
||||||
}, 5000);
|
}, 5000);
|
||||||
server.listen(0, () => {
|
server.listen(0, () => {
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
|
@ -1359,7 +1360,7 @@ Deno.test("[node/http] http.request() post streaming body works", async () => {
|
||||||
const response = JSON.parse(responseBody);
|
const response = JSON.parse(responseBody);
|
||||||
assertEquals(res.statusCode, 200);
|
assertEquals(res.statusCode, 200);
|
||||||
assertEquals(response.bytes, contentLength);
|
assertEquals(response.bytes, contentLength);
|
||||||
deferred.resolve();
|
responseEnded.resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1369,8 +1370,10 @@ Deno.test("[node/http] http.request() post streaming body works", async () => {
|
||||||
|
|
||||||
const readStream = fs.createReadStream(filePath);
|
const readStream = fs.createReadStream(filePath);
|
||||||
readStream.pipe(req);
|
readStream.pipe(req);
|
||||||
|
readStream.on("close", fileClosed.resolve);
|
||||||
});
|
});
|
||||||
await deferred.promise;
|
await responseEnded.promise;
|
||||||
|
await fileClosed.promise;
|
||||||
assertEquals(server.listening, true);
|
assertEquals(server.listening, true);
|
||||||
server.close();
|
server.close();
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
|
|
Loading…
Reference in a new issue