Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BunFile.slice() hangs if end is greater than length of file #5080

Closed
tryggvil opened this issue Sep 12, 2023 · 0 comments · Fixed by #5186
Closed

BunFile.slice() hangs if end is greater than length of file #5080

tryggvil opened this issue Sep 12, 2023 · 0 comments · Fixed by #5186
Assignees
Labels
bug Something isn't working

Comments

@tryggvil
Copy link

tryggvil commented Sep 12, 2023

What version of Bun is running?

1.0.0+b5a3bed7f2b0b511a5de3ba4a35813338b410703

What platform is your computer?

Darwin 22.6.0 arm64 arm

What steps can reproduce the bug?

When slicing a file, when end argument is greater than the total length of the file , the slice hangs.

const contents = "contents";
const sliceEndLargerThanFile = contents.length + 1024;

const blb = new Blob([contents]);
const blbSlice = blb.slice(2, sliceEndLargerThanFile);
const blActualContents = await blbSlice.text();
console.log("blob actualContents:", blActualContents);

await Bun.write("contents.txt", contents);

const fil = Bun.file("contents.txt");
const filSlice = fil.slice(2, sliceEndLargerThanFile);
const filActualContents = await filSlice.text();
console.log("file actualContents:", filActualContents);

This seems to be happening both on macOS and Linux.

What is the expected behavior?

blob actualContents: ntents
file actualContents: ntents

What do you see instead?

blob actualContents: ntents

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants