mirror of
https://github.com/denoland/deno.git
synced 2024-12-11 01:58:05 -05:00
fix: client closing a streaming request doesn't terminate server
This commit is contained in:
parent
858cf46894
commit
0488c79bba
1 changed files with 3 additions and 6 deletions
|
@ -1381,6 +1381,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(() => {
|
||||||
|
@ -1393,13 +1394,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;
|
||||||
|
@ -1429,9 +1430,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);
|
||||||
}
|
}
|
||||||
|
@ -1457,8 +1455,7 @@ Deno.test("[node/http] client closing a streaming request doesn't terminate serv
|
||||||
clearInterval(interval!);
|
clearInterval(interval!);
|
||||||
});
|
});
|
||||||
|
|
||||||
const IGNORED_X = "[node/http] http.request() post streaming body works";
|
Deno.test("[node/http] http.request() post streaming body works", async () => {
|
||||||
Deno.test(IGNORED_X, { ignore: Deno.build.os === "linux" }, async () => {
|
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
if (req.method === "POST") {
|
if (req.method === "POST") {
|
||||||
let receivedBytes = 0;
|
let receivedBytes = 0;
|
||||||
|
|
Loading…
Reference in a new issue