Skip to content

Commit

Permalink
Update fetch-tcp-stress.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Sep 27, 2024
1 parent 70cd12e commit 157c6ff
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/js/web/fetch/fetch-tcp-stress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function runStressTest({
socket.data ??= {};
socket.data.read = true;
sockets[i] = socket;
if (socket.write("200 OK\r\nCo") === "200 OK\r\nCo".length) {
if (socket.write("200 OK\r\n\r\n") === "200 OK\r\n\r\n".length) {
socket.data.written = true;
onServerWritten(socket);
}
Expand All @@ -56,7 +56,7 @@ async function runStressTest({
return;
}

if (socket.write("200 OK\r\nCo") === "200 OK\r\nCo".length) {
if (socket.write("200 OK\r\n\r\n") === "200 OK\r\n\r\n".length) {
socket.data.written = true;
onServerWritten(socket);
}
Expand All @@ -81,9 +81,11 @@ async function runStressTest({
toClose = batch;
for (let i = 0; i < batch; i++) {
promises.push(
fetch(`http://127.0.0.1:${server.port}`, objects[i]).finally(() => {
onFetchWritten(sockets[i]);
}),
fetch(`http://127.0.0.1:${server.port}`, objects[i])
.then(r => r.blob())
.finally(() => {
onFetchWritten(sockets[i]);
}),
);
}
await Promise.allSettled(promises);
Expand Down Expand Up @@ -120,7 +122,7 @@ test(
async () => {
await runStressTest({
onServerWritten(socket) {
socket.end();
socket.shutdown();
},
onFetchWritten(socket) {},
});
Expand Down

0 comments on commit 157c6ff

Please sign in to comment.