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 fs.readFile, fs.exists{Sync} regression caused by assertions #17852

Closed
wants to merge 2 commits into from

Conversation

joyeecheung
Copy link
Member

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

fs

Refs: #17667

#17667 didn't include the path validation of these methods in JS land, so passing undefined as paths to them would go straight to assertions, which caused CITGM regression https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1165/ . This PR fixes that by adding those validations back.

@nodejs-github-bot nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Dec 24, 2017
@joyeecheung
Copy link
Member Author

joyeecheung commented Dec 24, 2017

@joyeecheung joyeecheung added the semver-major PRs that contain breaking changes and should be released in the next major version. label Dec 24, 2017
@@ -340,6 +340,10 @@ fs.accessSync = function(path, mode) {
fs.exists = function(path, callback) {
if (handleError((path = getPathFromURL(path)), cb))
return;
if (typeof path !== 'string' && !(path instanceof Buffer)) {
Copy link
Contributor

@starkwang starkwang Dec 25, 2017

Choose a reason for hiding this comment

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

Should these type checks be placed at the beginning of these methods?

Copy link
Member

@Trott Trott Dec 25, 2017

Choose a reason for hiding this comment

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

@starkwang No because the check must happen after getPathFromURL(path) is called. The path may be a string, a Buffer, or a URL-like object.

@joyeecheung
Copy link
Member Author

joyeecheung commented Dec 26, 2017

@joyeecheung joyeecheung added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. dont-land-on-v4.x and removed semver-major PRs that contain breaking changes and should be released in the next major version. labels Dec 27, 2017
@joyeecheung
Copy link
Member Author

joyeecheung commented Dec 27, 2017

This is not semver-major itself, it just fixes regressions in #17667 which is semver-major. So added dont land labels instead.

@joyeecheung
Copy link
Member Author

joyeecheung commented Dec 27, 2017

:/ ... ah, right, technically speaking the previous behavior is "throwing old-style type errors", so this is still semver-major. @nodejs/tsc this needs one more TSC approval to land, please review

@joyeecheung joyeecheung added semver-major PRs that contain breaking changes and should be released in the next major version. and removed dont-land-on-v4.x author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Dec 27, 2017
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@apapirovski
Copy link
Member

Landed in 9ec700b and 71396a2

🎉

apapirovski pushed a commit that referenced this pull request Dec 27, 2017
PR-URL: #17852
Refs: #17667
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
apapirovski pushed a commit that referenced this pull request Dec 27, 2017
PR-URL: #17852
Refs: #17667
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
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. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants