-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
v14.10.0 changes behavior of existing code (got) #35116
Comments
Reproduction: require('got')('https://www.google.com').then(console.log, console.log) This logs the response in Node.js 14.9.0 and exits without any logs in Node.js 14.10.0 |
I'm bisecting... |
4bb4007 is the first bad commit
|
Would someone mind to dig into this a bit a look exactly where in got the problem occurs? I'm a bit swamped today but might be able to take a look if I know more specifically where e.g. async generators come into play? |
Should got be added to CITGM? |
Got was disabled in CITGM because there were issues with ESLint that made it always fail: nodejs/citgm#825, nodejs/citgm#795 |
This happens because The promise never resolves because The Lines 1117 to 1119 in 1204400
|
This comment has been minimized.
This comment has been minimized.
Ok, this might actually be an error in the PR. We should not call destroy before end has been emitted. I'll try to prepare a PR tonight. If someone wants to work on it asap something like this should fix it: try {
const state = stream._readableState;
while (true) {
const chunk = stream.read();
if (chunk !== null) {
yield chunk;
} else if (state.errored) {
throw state.errored;
} else if (state.endEmitted) {
break;
} else if (state.closed) {
// TODO(ronag): ERR_PREMATURE_CLOSE?
break;
} else {
await new Promise(next);
}
}
} catch (err) {
destroyImpl.destroyer(stream, err);
throw err;
} finally {
destroyImpl.destroyer(stream, null);
} i.e. change |
I'm not sure whether the above will resolve the referenced issue though. |
I've just tested it and it does not 😞.
We should unskip it in the lookup if we can. FWIW you can run "citgm got" instead of "citgm-all" to still test the module, e.g. against the current Edit: CI contains lint warnings similar to nodejs/citgm#795 but the test is also timed out. |
Unfortunately it looks like If we do need to push a new release we should aim to do that by tomorrow (Thursday 10th September) at the latest since:
I can push out a new release if required. Questions:
cc @nodejs/releasers @nodejs/tsc |
I think I've managed to figure out the problem. The old async iterator didn't destroy on success and got assumes destroy is an error. |
@targos is right. The |
So @ronag is also right. Node.js 14.10.0 broke |
@richardlau should we be reverting from master as well? |
I just spent like 6 hours trying to figure out why I was getting async function getParsedBody(request) {
let body = ''
for await (const chunk of request) {
body += chunk
}
try {
return JSON.parse(body)
} catch {
return {}
}
} When I remove the |
@szmarczak note that this is a bug on @MylesBorins it should be reverted in v14 and then fixed on master and v15. |
@joaopaulobdac would you mind providing a complete example? Are you also using got? |
I'm not using got or anything. Sorry for throwing that code example at you out of nowhere! It's just that I have a raw node http server and I call I downgraded node to 14.9.0 and the server handles requests normally again. |
Why is it so? |
@joaopaulobdac That's great information! Any chance you could share a minimal reproducible example? |
@szmarczak We are reverting the change. There is a problem with got but as you said we should not cause such a breaking change in semver-minor. I'm sorry for the inconvenience this has caused. Did not consider this. That being said I'd very much appreciate if you could continue helping with a fix in v15 and making got pass in CITGM. |
I meant that if Got was to use
No problem. I'm glad that we see this "bug" sooner than later :D
I've been actually debugging for ~10 mins and have no thoughts to stop. I'm continuing :) |
@ronag Here you go: const http = require('http')
async function getParsedBody(request) {
let body = ''
for await (const chunk of request) {
body += chunk
}
try {
return JSON.parse(body)
} catch {
return {}
}
}
const server = http.createServer(async (request, response) => {
const body = await getParsedBody(request)
response.statusCode = 200
response.end(JSON.stringify(body))
})
server.listen(3000) $ node -v
v14.9.0
$ http POST http://localhost:3000/ test=testing
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 18
Date: Thu, 10 Sep 2020 08:15:17 GMT
Keep-Alive: timeout=5
{"test":"testing"} $ node -v
v14.10.0
$ http POST http://localhost:3000/ test=testing
http: error: ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) while doing a POST request to URL: http://localhost:3000/ |
I believe this has been resolved in latest 14.x. |
What steps will reproduce the bug?
got@11.6.1
hangs when running under v14.10.0. Works fine under earlier versions, including v14.9.0. See sindresorhus/got#1441 for more details.As v14.10.0 was a minor version bump, I wouldn't expect it to break existing code.
How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior?
got
can make a request successfullyWhat do you see instead?
got
hangs indefinitely (promise doesn't resolve - not sure why)Additional information
got
has over 12 million weekly downloads. This issue should probably be addressed quickly.The text was updated successfully, but these errors were encountered: