diff --git a/src/s3.zig b/src/s3.zig index 982242a7506fb2..99136c01d2e771 100644 --- a/src/s3.zig +++ b/src/s3.zig @@ -1353,15 +1353,6 @@ pub const AWSCredentials = struct { ); return; } - if (chunk.list.items.len == 0) { - readable.ptr.Bytes.onData( - .{ - .done = {}, - }, - bun.default_allocator, - ); - return; - } readable.ptr.Bytes.onData( .{ .temporary_and_done = bun.ByteList.initConst(chunk.list.items), @@ -1371,8 +1362,6 @@ pub const AWSCredentials = struct { return; } } - var buffer = chunk; - buffer.deinit(); } pub fn deinit(this: *@This()) void { diff --git a/test/js/bun/s3/s3-stream-leak-fixture.js b/test/js/bun/s3/s3-stream-leak-fixture.js index 44b2f4a1c77727..8fa65e8220424f 100644 --- a/test/js/bun/s3/s3-stream-leak-fixture.js +++ b/test/js/bun/s3/s3-stream-leak-fixture.js @@ -27,11 +27,10 @@ async function run(inputType) { } MAX_ALLOWED_MEMORY_USAGE = ((process.memoryUsage.rss() / 1024 / 1024) | 0) + MAX_ALLOWED_MEMORY_USAGE_INCREMENT; { - await Promise.all(new Array(10).fill(readLargeFile())); + await Promise.all(new Array(20).fill(readLargeFile())); Bun.gc(true); } const rss = (process.memoryUsage.rss() / 1024 / 1024) | 0; - console.log("Memory usage:", rss, "MB"); if (rss > MAX_ALLOWED_MEMORY_USAGE) { await s3file.unlink(); throw new Error("Memory usage is too high"); diff --git a/test/js/bun/s3/s3.test.ts b/test/js/bun/s3/s3.test.ts index 708ff3bbe15fe2..ca87dd9fca9e40 100644 --- a/test/js/bun/s3/s3.test.ts +++ b/test/js/bun/s3/s3.test.ts @@ -620,7 +620,7 @@ describe.skipIf(!s3Options.accessKeyId)("s3", () => { it( "fsFile.stream() should not leak", async () => { - const dir = tempDirWithFiles("bun-write-leak-fixture", { + const dir = tempDirWithFiles("s3-stream-leak-fixture", { "s3-stream-leak-fixture.js": await Bun.file(path.join(import.meta.dir, "s3-stream-leak-fixture.js")).text(), "out.bin": "here", }); @@ -651,7 +651,7 @@ describe.skipIf(!s3Options.accessKeyId)("s3", () => { it( "fsFile.writer().write() should not leak", async () => { - const dir = tempDirWithFiles("bun-write-leak-fixture", { + const dir = tempDirWithFiles("s3-writer-leak-fixture", { "s3-writer-leak-fixture.js": await Bun.file(path.join(import.meta.dir, "s3-writer-leak-fixture.js")).text(), "out.bin": "here", });