fs: filehandle.read(buffer) can't read file when options are omitted
fix: #47183 (closed)
- make length arg in fh.read(buffer, offset, position, length) default to
length ?? buffer.byteLength - offset
Code
import fs from "fs/promises";
async function test() {
let path = './ex.txt';
let buf = Buffer.alloc(4);
let handle;
try {
handle = await fs.open(path);
{
let buf = Buffer.alloc(4);
let { bytesRead, buffer } = await handle.read(buf);
console.log(bytesRead);
console.log(buffer);
console.log(buf);
}
} finally {
await handle?.close();
}
}
test();
before
0
<Buffer 00 00 00 00>
<Buffer 00 00 00 00>
now
4
<Buffer 48 65 6c 6c>
<Buffer 48 65 6c 6c>
That's my second attempt at this issue