-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Return string rather than Buffer on response #100
Conversation
In previous versions of Dockerode, this was expected behaviour. 2.5.8 broke this, and now returns a Buffer when the `parseJSON` fails. This PR returns the stringified buffer even when this fails, rather than the Buffer object.
If this is a change that was intentional, then it should probably bump SemVer for a major change. This is not backwards compatible. |
This was introduced in: Indeed this got pushed into the wrong version, causing this backward compatibility issue. |
Yes lets revert this and then bump the version. |
Perfect, thanks. 👍 |
What was the thought behind this? Docker logs are not utf8 Strings! Buffer.toString() uses utf8 by default: By blindly converting a Buffer to a utf8 string, junk characters are introduced in the beginning of each line. Getting logs from container now contains junk chars if it's not a stream. @Cherry / @apocas had you tested this before merging? This should be reverted back to Buffer. Otherwise, demuxing is impossible. I'll create a new PR converting this back to Buffer unless there is a way for demuxing that I cannot think of? |
@githubsaturn This PR was solely issued to restore the behaviour in Dockerode 2.5.7, that was broken in 2.5.8. Dockerode always returned strings prior to #97. I'm not against using a Buffer and would +1 this change if a new major version was issued as per SemVer, since this would be a breaking change, but this unannounced breaking change broke our build in the past, thus this PR was created to restore the original behaviour. See apocas/dockerode#456 for more discussion. |
I'd argue that this broke the backward compatibility because of a bugfix. Keeping a buggy implementation for the sake of not changing the behavior is less than desirable IMHO. Anyways, this is what I suggest:
@apocas |
I agree it's less than desirable, but given it was this way for years, there's a lot of code in the wild that relies on it. Nevertheless, I'd +1 bumping a major version for dockerode and docker-modem for fixing this. |
This weekend I will release new major versions for both of projects, fixing this and improving the promise based interfaces. |
Closing #100 Will be published along the bump to 2.x.x
In previous versions of Dockerode, this was expected behaviour (to an extent, but a
stream
was generally expected prior to this issue). 2.5.8 broke this, and now returns a Buffer when theparseJSON
fails. This PR returns the stringified buffer even when this fails, rather than the Buffer object.