Skip to content

Conversation

@mscdex
Copy link
Contributor

@mscdexmscdex commented Nov 18, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)
  • fs
Description of change

Even though an Error object is passed to the callback when readFile() fails due to toString() failing, it is a bit strange to still see data passed as the second argument. This commit changes that and only
passes the Error object in that case.

CI: https://ci.nodejs.org/job/node-test-pull-request/4877/

@mscdexmscdex added 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. labels Nov 18, 2016
@nodejs-github-botnodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Nov 18, 2016
Copy link
Member

@targostargos left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@sam-githubsam-github left a comment

Choose a reason for hiding this comment

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

Isn't the bufer useful? Particularly here, converting the Buffer to a string failed, but the buffer was sucessfully read, so why not return the data?

lib/fs.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this move to line 401, before the buffer object (which is no longer being passed), goes through the code to create/change it?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

@mscdexmscdexforce-pushed the fs-tostring-failure-callback branch from 733e8e6 to 7b18106CompareNovember 18, 2016 19:51
@mscdex
Copy link
ContributorAuthor

mscdex commented Nov 18, 2016

@sam-github I think it's more confusing not only because we don't do that for any other node core API (that I am aware of) but because if you asked for a string, I would never expect a Buffer -- whether there was an error or not. Also, the Buffer is probably useless in most cases since there is usually a reason why a string was requested.

@mscdex
Copy link
ContributorAuthor

@mscdex
Copy link
ContributorAuthor

mscdex commented Dec 14, 2016

Even though an Error object is passed to the callback when readFile() fails due to toString() failing, it is a bit strange to still see data passed as the second argument. This commit changes that and only passes the Error object in that case. PR-URL: nodejs#9670 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: James M Snell <[email protected]>
@mscdexmscdexforce-pushed the fs-tostring-failure-callback branch from dc918d7 to f3cf8e9CompareDecember 14, 2016 08:31
@mscdexmscdex merged commit f3cf8e9 into nodejs:masterDec 14, 2016
@mscdexmscdex deleted the fs-tostring-failure-callback branch December 14, 2016 08:34
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 18, 2017
Even though an Error object is passed to the callback when readFile() fails due to toString() failing, it is a bit strange to still see data passed as the second argument. This commit changes that and only passes the Error object in that case. PR-URL: nodejs#9670 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: James M Snell <[email protected]>
@jasnelljasnell mentioned this pull request Apr 4, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fsIssues and PRs related to the fs subsystem / file system.semver-majorPRs 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

@mscdex@sam-github@jasnell@thefourtheye@princejwesley@targos@cjihrig@nodejs-github-bot