-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
HTTP parser premature close #29609
Comments
This might also be an interaction with streams and/or the test's makeDuplexPair implementation, since this works: const serverSide = new Duplex;
serverSide._read = function(){};
serverSide._write = function(chunk, enc, cb){
console.log(chunk.toString());
cb();
};
serverSide._final = function(){
console.log('(Connection close)');
}
serverSide.push(message); producing the expected output:
Adding
|
Case 2 works as expected in Node.js v10.16.3:
|
I suspect this is a bad interaction between multiple components:
|
Just pinging myself here. I'll take a look later this to see if I can help make sense of this one. |
It appears this is caused by an underlying bug in streams and/or the duplex pair implementation: 'use strict';
const common = require('./test/common');
const makeDuplexPair = require('./test/common/duplexpair');
const { clientSide, serverSide } = makeDuplexPair();
serverSide.resume();
serverSide.on('end', function(buf){
serverSide.write('out');
serverSide.write('');
serverSide.end();
});
clientSide.end();
clientSide.on('data', function(m){
console.log(m.toString());
});
clientSide.on('end', common.mustCall(function(){
console.log('(Connection closed)');
})); Expected:
Actual:
A write call (empty or non-empty) followed by an empty write call causes this; note how removing either of the calls works around the bug. This isn't related to HTTP so I'm not sure if/when this was ever introduced, I'll spin up a "git bisect" job soon. |
This has been around since at least v10.16.3 |
As far as I can tell the bug I'm encountering isn't "http" related, so I've opened #29758 |
I'm running across an issue where when no response data is written during the "request" event call, the HTTP handling either closes the response without sending any apparent reply, or sends a
Connection: close
response but doesn't end the stream.This is a strange behavior that I can't find an explanation for and I can't come up with any workaround; so I think this is a bug.
Case 1
Actual:
I expect to see the HTTP response output, but the connection simply closes.
Case 2 (using clientSide.write instead of clientSide.end)
I expect to see
(Connection closed)
at the end, but I do not.Actual:
In one or the other case I expect:
As far as I can tell, there's no way to do this.
The text was updated successfully, but these errors were encountered: