fs: do not pass Buffer when toString() fails#9670
Merged
mscdex merged 1 commit intonodejs:masterfrom Dec 14, 2016
Merged
Conversation
cjihrig
approved these changes
Nov 18, 2016
thefourtheye
approved these changes
Nov 18, 2016
princejwesley
approved these changes
Nov 18, 2016
jasnell
approved these changes
Nov 18, 2016
sam-github
reviewed
Nov 18, 2016
Contributor
sam-github
left a comment
There was a problem hiding this comment.
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?
Contributor
There was a problem hiding this comment.
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?
733e8e6 to
7b18106
Compare
Contributor
Author
|
@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. |
Contributor
Author
Contributor
Author
7b18106 to
dc918d7
Compare
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]>
dc918d7 to
f3cf8e9
Compare
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
make -j8 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
Description of change
Even though an Error object is passed to the callback when
readFile()fails due totoString()failing, it is a bit strange to still see data passed as the second argument. This commit changes that and onlypasses the Error object in that case.
CI: https://ci.nodejs.org/job/node-test-pull-request/4877/