Fix fd offset handling in ReadStream (#10883)

Co-authored-by: Georgijs Vilums <=>
Co-authored-by: gvilums <gvilums@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
Georgijs
2024-05-07 16:05:48 -07:00
committed by GitHub
parent 6217d78567
commit d4db29c164
6 changed files with 143 additions and 55 deletions

View File

@@ -1815,6 +1815,24 @@ describe("createReadStream", () => {
done();
});
});
it(
"correctly handles file descriptors with an offset",
done => {
const path = `${tmpdir()}/bun-fs-createReadStream-${Date.now()}.txt`;
const fd = fs.openSync(path, "w+");
const stream = fs.createReadStream("", { fd: fd, start: 2 });
stream.on("data", chunk => {
expect(chunk.toString()).toBe("llo, world!");
done();
});
stream.on("error", done);
fs.writeSync(fd, "Hello, world!");
},
{ timeout: 100 },
);
});
describe("fs.WriteStream", () => {