v14.0.0MacOS Catalina11.5.0Trying to make a very simple HTTP request and the response body is always empty. Tried reading the docs couple of times, ensuring I haven't missed anything. But nope.
The response.body is an empty string
Should return the response returned by the server
const got = require("got")
got.get('http://jsonplaceholder.typicode.com/todos/1').then((response) => {
console.log(response.body)
})
Just to make sure, that there isn't anything wrong on my end. I also tried using the Node.js http client to make the request to the same URL and it works fine.
Sample code for same
http.get('http://jsonplaceholder.typicode.com/todos/1', (response) => {
let rawData = ''
response.on('data', (chunk) => { rawData += chunk; })
response.on('end', () => {
console.log(rawData)
});
})
In action

Haven't been able to dig deeper. But the code works fine on 11.3.0 and not on 11.4.0 and 11.5.0. Seems like on of the following commits have caused the issue
Latest Got (11.5.0)
On my end the body is empty on Node.JS 14.0.0, but it works fine on 14.5.0 (latest version).
Tested on all [supported] latest Node.js and it works as expected. Please update your Node.js version.
@szmarczak Are you collecting points by quickly closing the issues?
When someone creates an issue, they are not opening it to just have fun. First try to have a dialogue. But anyways
Here's the output of tests on node v14.0.0.

If you suggest to upgrade to v14.5.0, then please share some reasons behind it
ping @sindresorhus ^^
Are you collecting points by quickly closing the issues?
Closing an issue just means it's resolved from our perspective. It doesn't mean we won't respond to additional comments.
If you suggest to upgrade to v14.5.0, then please share some reasons behind it
Uhm, the bug is fixed.
I feel like you're assuming this is a Got bug, while in fact most bugs in Got are really Node.js bugs. It's just that Got is a heavy user of the Node.js HTTP and stream APIs so Node.js bugs become quite apparent here. We cannot reasonable work around all the Node.js bugs, especially not ones that are already fixed in Node.js patch versions. By not upgrading patch versions, you're also exposing yourself to security vulnerabilities.
For reference, @szmarczak has opened 33 Node.js issues and that's just a small percentage of all the bugs we have encountered.
Never strictly said it is a got bug. Also, it is impossible for an outsider to know which bugs falls in the Node.js land and which falls in Got land (you guys have history with the module, so understand the blurry lines better)
Was trying to report what I discovered and shared proper context
You reported a bug and we provided a solution. I don't really see what the issue is here.
To add to the discussion, I found that node.js versions 14.0.0 and 14.1.0 seem to be both having the same issue @thetutlage reported.
Upgrading to at least >= 14.2.0 seems to resolve it from an upgrade perspective.
Most helpful comment
You reported a bug and we provided a solution. I don't really see what the issue is here.