Skip to content

Bun.write cannot write files over 2 GB #8254

Open
@tnraro

Description

@tnraro

What version of Bun is running?

1.0.23+83f2432da

What platform is your computer?

Linux 5.15.133.1-microsoft-standard-WSL2 x86_64 unknown

What steps can reproduce the bug?

The size of the file was the same as the original, but in my case, it was filled with zero from 2,147,479,553 bytes.

Here's a simple script to write a file that just read. It also prints checksum (A).

import { CryptoHasher, file, write } from "bun";

const buffer = await file("/some-large-file.mkv").arrayBuffer()

const hasher = new CryptoHasher("sha1")
hasher.update(buffer)
console.log(hasher.digest("hex"))

await write("out.mkv", buffer)

Checksum changes when /some-large-file.mkv exceeds 2 GB. (A and B are the same, C is different.)

$ sha1sum some-large-file.mkv # (B)
$ sha1sum out.mkv # (C)

What is the expected behavior?

The same bytes as the original file should be filled.

What do you see instead?

It was filled with zero

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbun:fs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions