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

Wrong type on buffer response #149

Closed
gallynero opened this issue Oct 21, 2022 · 3 comments
Closed

Wrong type on buffer response #149

gallynero opened this issue Oct 21, 2022 · 3 comments

Comments

@gallynero
Copy link
Contributor

I am trying to make the log examples and they do not work and send the following error:

stream.on('data', processData); ^ TypeError: stream.on is not a function at Modem.demuxStream (/workspace/1_Project/1_Sources/node_modules/docker-modem/lib/modem.js:410:10)

Because the returned stream is of type Buffer and not of type ReadableStream, I think the bug is in this line:

var json = utils.parseJSON(result) || buffer;

Which should be:

var json = utils.parseJSON(result) || Readable.from(buffer);

I will send a pull request with the change please review it.

@q0rban
Copy link

q0rban commented Oct 11, 2023

Looks like this can be closed now as #150 has been merged.

@apocas
Copy link
Owner

apocas commented Oct 11, 2023

Crap, in reality this shouldn't be a stream.
The logs method send the "isStream" parameter if the "follow" parameter is true.

Docker-modem only returns a stream if the isStream is specified. I missed this.

The logs example work. Did you change the "follow" parameter to false?

@apocas
Copy link
Owner

apocas commented Oct 11, 2023

If JSON parsing fails we should just return the string, instead of the buffer though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants