aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/fetch
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-08-23 14:05:05 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-23 14:05:05 -0700
commitc60385716b7a7ac9f788cdf7dfe37250321e0670 (patch)
treeb08cc97e7e9d456efac7ec83d4862c8a8e3043bf /test/js/web/fetch
parentf3266ff436e0ed2aedd0d81f47a1ef104191a2c9 (diff)
downloadbun-c60385716b7a7ac9f788cdf7dfe37250321e0670.tar.gz
bun-c60385716b7a7ac9f788cdf7dfe37250321e0670.tar.zst
bun-c60385716b7a7ac9f788cdf7dfe37250321e0670.zip
Bunch of streams fixes (#4251)
* Update WebKit * Don't do async hooks things when async hooks are not enabled * Smarter scheduling of event loop tasks with the http server * less exciting approach * Bump WebKit * Another approach * Fix body-stream tests * Fixes #1886 * Fix UAF in fetch body streaming * Missing from commit * Fix leak * Fix the other leak * Fix test * Fix crash * missing duperef * Make this code clearer * Ignore empty chunks * Fixes #3969 * Delete flaky test * Update bun-linux-build.yml * Fix memory issue * fix result body, and .done status before the last callback, dont touch headers after sent once * refactor HTTPClientResult * less flasky corrupted test * oops * fix mutex invalid state * fix onProgressUpdate deinit/unlock * fix onProgressUpdate deinit/unlock * oops * remove verbose * fix posible null use * avoid http null * metadata can still be used onReject after toResponse * dont leak task.http * fix flask tests * less flask close tests --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
Diffstat (limited to 'test/js/web/fetch')
-rw-r--r--test/js/web/fetch/fetch.stream.test.ts31
1 files changed, 17 insertions, 14 deletions
diff --git a/test/js/web/fetch/fetch.stream.test.ts b/test/js/web/fetch/fetch.stream.test.ts
index efef6a161..dc082fd2f 100644
--- a/test/js/web/fetch/fetch.stream.test.ts
+++ b/test/js/web/fetch/fetch.stream.test.ts
@@ -412,8 +412,7 @@ describe("fetch() with streaming", () => {
const fixture = matrix[i];
for (let j = 0; j < matrix.length; j++) {
const fixtureb = matrix[j];
- const test = fixture.name == "empty" && fixtureb.name == "empty" ? it.todo : it;
- test(`can handle fixture ${fixture.name} x ${fixtureb.name}`, async () => {
+ it(`can handle fixture ${fixture.name} x ${fixtureb.name}`, async () => {
let server: Server | null = null;
try {
//@ts-ignore
@@ -917,12 +916,11 @@ describe("fetch() with streaming", () => {
drain(socket) {},
},
});
-
- const res = await fetch(`http://${server.hostname}:${server.port}`, {
- signal: AbortSignal.timeout(1000),
- });
- gcTick(false);
try {
+ const res = await fetch(`http://${server.hostname}:${server.port}`, {
+ signal: AbortSignal.timeout(1000),
+ });
+ gcTick(false);
const reader = res.body?.getReader();
let buffer = Buffer.alloc(0);
@@ -995,6 +993,7 @@ describe("fetch() with streaming", () => {
compressed[0] = 0; // corrupt data
cork = false;
for (var i = 0; i < 5; i++) {
+ compressed[size * i] = 0; // corrupt data even more
await write(compressed.slice(size * i, size * (i + 1)));
}
socket.flush();
@@ -1003,10 +1002,10 @@ describe("fetch() with streaming", () => {
},
});
- const res = await fetch(`http://${server.hostname}:${server.port}`, {});
- gcTick(false);
-
try {
+ const res = await fetch(`http://${server.hostname}:${server.port}`, {});
+ gcTick(false);
+
const reader = res.body?.getReader();
let buffer = Buffer.alloc(0);
@@ -1079,23 +1078,27 @@ describe("fetch() with streaming", () => {
// 10 extra missing bytes that we will never sent in this case we will wait to close
await write("Content-Length: " + compressed.byteLength + 10 + "\r\n");
await write("\r\n");
+
+ resolveSocket(socket);
+
const size = compressed.byteLength / 5;
for (var i = 0; i < 5; i++) {
cork = false;
await write(compressed.slice(size * i, size * (i + 1)));
}
socket.flush();
- resolveSocket(socket);
},
drain(socket) {},
},
});
- const res = await fetch(`http://${server.hostname}:${server.port}`, {});
- gcTick(false);
+ let socket: Socket | null = null;
- let socket: Socket | null = await promise;
try {
+ const res = await fetch(`http://${server.hostname}:${server.port}`, {});
+ socket = await promise;
+ gcTick(false);
+
const reader = res.body?.getReader();
let buffer = Buffer.alloc(0);