Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/__test__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ beforeAll(() => {

afterAll(() => {
server.close();
uninstallHacks();
});

describe("tsw index", () => {
Expand Down
1 change: 1 addition & 0 deletions lib/core/runtime/capture/__test__/incoming.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe("capture response function test", () => {
path: "/",
method: "POST",
headers: {
Connection: "Close",
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": Buffer.byteLength(data)
}
Expand Down
15 changes: 11 additions & 4 deletions lib/core/runtime/capture/incoming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ export const captureReadableStream = (
info.bodyTooLarge = info.bodyLength > maxBodySize;
};

let { head } = (stream as any).readableBuffer;
while (head) {
handler(head.data);
head = head.next;
const rb = (stream as any).readableBuffer;
let { head } = rb;
if (head !== undefined) {
while (head) {
handler(head.data);
head = head.next;
}
} else if (rb.forEach) {
rb.forEach((c) => {
handler(c);
});
}

(stream as any).push = (chunk: any, encoding?: string): boolean => {
Expand Down