You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
filehandle.read(buffer) can't read file when options are omitted #47183
Linux ubuntu-focal 5.4.0-144-generic #161-Ubuntu SMP Fri Feb 3 14:49:04 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
constfs=require("fs/promises");asyncfunctiontest(){letpath='/path/to/file';letbuf=Buffer.alloc(4);lethandle;try{handle=awaitfs.open(path);{letbuf=Buffer.alloc(4);let{ bytesRead, buffer }=awaithandle.read(buf);//let { bytesRead, buffer } = await handle.read(buf, {}); // It is behavior I would expect.console.log(bytesRead);console.log(buffer);console.log(buf);}}finally{awaithandle?.close();}}test();
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
changed the title [-]filehandle.read(buffer) can't read file when options are ommitted[/-][+]filehandle.read(buffer) can't read file when options are omitted[/+]on Mar 21, 2023
Activity
H1Gdev commentedon Mar 21, 2023
node/lib/internal/fs/promises.js
Lines 569 to 571 in a94966f
It looks like the length is still zero here.
Adding the following might work as expected.
[-]Can not read file.[/-][+]filehandle.read(buffer) can't read file when options are ommitted[/+][-]filehandle.read(buffer) can't read file when options are ommitted[/-][+]filehandle.read(buffer) can't read file when options are omitted[/+]pulkit-30 commentedon Dec 7, 2023
is this issue valid? please confirm.
fs: make offset, position & length args in fh.read() optional
fs: make offset, position & length args in fh.read() optional
markrian commentedon Jan 2, 2024
Edit: Oh, I see #51087 probably fixes this. Sorry for the noise!
@pulkit-30 I can still reproduce this on node 21.5.0 and 20.10.0 with this script:
Invoked like this:
Produces this output:
fs: make offset, position & length args in fh.read() optional