aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js
diff options
context:
space:
mode:
authorGravatar Ciro Spaciari <ciro.spaciari@gmail.com> 2023-03-01 18:07:21 -0300
committerGravatar GitHub <noreply@github.com> 2023-03-01 13:07:21 -0800
commit56ca48ece88c0de854ec20c5e71a639fee6ccb0f (patch)
tree6161cccbd4bc5ce3f72e2ccfea9e25a8513a26cf /test/bun.js
parent530cf4caf8abe4960d833efc6cce71188dea40b2 (diff)
downloadbun-56ca48ece88c0de854ec20c5e71a639fee6ccb0f.tar.gz
bun-56ca48ece88c0de854ec20c5e71a639fee6ccb0f.tar.zst
bun-56ca48ece88c0de854ec20c5e71a639fee6ccb0f.zip
fix Bun.file.arrayBuffer() segmentation fault on empty file #2248 (#2249)
* fix Bun.file.arrayBuffer() segmentation fault on empty file #2248 * cleanner this.iotask check
Diffstat (limited to 'test/bun.js')
-rw-r--r--test/bun.js/bun-write.test.js8
-rw-r--r--test/bun.js/emptyFile0
2 files changed, 8 insertions, 0 deletions
diff --git a/test/bun.js/bun-write.test.js b/test/bun.js/bun-write.test.js
index 7e1d43059..68e221d51 100644
--- a/test/bun.js/bun-write.test.js
+++ b/test/bun.js/bun-write.test.js
@@ -139,6 +139,14 @@ it("Bun.file", async () => {
await gcTick();
});
+it("Bun.file empty file", async () => {
+ const file = path.join(import.meta.dir, "emptyFile");
+ await gcTick();
+ const buffer = await Bun.file(file).arrayBuffer()
+ expect(buffer.byteLength).toBe(0);
+ await gcTick();
+});
+
it("Bun.file as a Blob", async () => {
const filePath = path.join(import.meta.path, "../fetch.js.txt");
const fixture = fs.readFileSync(filePath, "utf8");
diff --git a/test/bun.js/emptyFile b/test/bun.js/emptyFile
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test/bun.js/emptyFile