mirror of
https://github.com/denoland/deno.git
synced 2024-12-18 13:22:55 -05:00
test(ext/node): reduce race condition in test case (#27207)
This commit is contained in:
parent
8cd257de3d
commit
32b4c37c05
1 changed files with 2 additions and 4 deletions
|
@ -1370,6 +1370,7 @@ Deno.test("[node/http] client closing a streaming request doesn't terminate serv
|
||||||
let interval: number;
|
let interval: number;
|
||||||
let uploadedData = "";
|
let uploadedData = "";
|
||||||
let requestError: Error | null = null;
|
let requestError: Error | null = null;
|
||||||
|
const deferred1 = Promise.withResolvers<void>();
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
res.writeHead(200, { "Content-Type": "text/plain" });
|
res.writeHead(200, { "Content-Type": "text/plain" });
|
||||||
interval = setInterval(() => {
|
interval = setInterval(() => {
|
||||||
|
@ -1382,13 +1383,13 @@ Deno.test("[node/http] client closing a streaming request doesn't terminate serv
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
});
|
});
|
||||||
req.on("error", (err) => {
|
req.on("error", (err) => {
|
||||||
|
deferred1.resolve();
|
||||||
requestError = err;
|
requestError = err;
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const deferred1 = Promise.withResolvers<void>();
|
|
||||||
server.listen(0, () => {
|
server.listen(0, () => {
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
const port = (server.address() as any).port;
|
const port = (server.address() as any).port;
|
||||||
|
@ -1418,9 +1419,6 @@ Deno.test("[node/http] client closing a streaming request doesn't terminate serv
|
||||||
|
|
||||||
if (sentChunks >= 3) {
|
if (sentChunks >= 3) {
|
||||||
client.destroy();
|
client.destroy();
|
||||||
setTimeout(() => {
|
|
||||||
deferred1.resolve();
|
|
||||||
}, 40);
|
|
||||||
} else {
|
} else {
|
||||||
setTimeout(writeChunk, 10);
|
setTimeout(writeChunk, 10);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue