-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Conversation
@@ -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)) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
This is not semver-major itself, it just fixes regressions in #17667 which is semver-major. So added dont land labels instead. |
:/ ... 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR-URL: #17852 Refs: #17667 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
PR-URL: #17852 Refs: #17667 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected 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.