Skip to content

Commit

Permalink
Wrap Body#formData() Buffer chunks in Uint8Arrays
Browse files Browse the repository at this point in the history
Workaround for nodejs/undici#1601
  • Loading branch information
mrbbot committed Aug 15, 2022
1 parent 7646912 commit 8d78294
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/standards/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ export class Body<Inner extends BaseRequest | BaseResponse> {
busboy.on("file", (name, value, info) => {
const { filename, encoding, mimeType } = info;
const base64 = encoding.toLowerCase() === "base64";
const chunks: Buffer[] = [];
const chunks: Uint8Array[] = [];
let totalLength = 0;
value.on("data", (chunk: Buffer) => {
if (base64) chunk = Buffer.from(chunk.toString(), "base64");
chunks.push(chunk);
chunks.push(new Uint8Array(chunk));
totalLength += chunk.byteLength;
});
value.on("end", () => {
Expand Down

0 comments on commit 8d78294

Please sign in to comment.