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

fs: fix filehandle.read(buffer) can't read file when options are omitted #47185

Closed
wants to merge 3 commits into from

Conversation

pulkit-30
Copy link
Contributor

@pulkit-30 pulkit-30 commented Mar 21, 2023

Fix #47183

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Mar 21, 2023
@H1Gdev H1Gdev mentioned this pull request Mar 21, 2023
@deokjinkim
Copy link
Contributor

/cc @nodejs/fs

test/parallel/test-fs-promises-file-handle-read.js Outdated Show resolved Hide resolved
Comment on lines +580 to +584
if (length == null) {
length = buffer.byteLength - offset;
} else {
length |= 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from fh.read(buffer), this change will also affect fh.read(buffer, offset, undefined, position) and fh.read(buffer, offset, null, position).
position and length in this signature are not optional, hence there's no default value.
How about adding arguments.length check instead?
Alternatively, we can consider a semver-major PRs that contain breaking changes and should be released in the next major version. change making last positional arguments optional and aligning fs.read() and fs.readSync() accordingly.

@pulkit-30 pulkit-30 closed this Nov 20, 2023
@pulkit-30 pulkit-30 deleted the fix-47183 branch December 6, 2023 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

filehandle.read(buffer) can't read file when options are omitted
4 participants