Compare commits

...

1 Commits

Author SHA1 Message Date
Jarred Sumner
618819a293 Add http server unconsume test and tweak close 2025-05-29 15:49:38 -07:00
2 changed files with 32 additions and 1 deletions

View File

@@ -796,7 +796,6 @@ const ServerPrototype = {
if (typeof optionalCallback === "function") process.nextTick(optionalCallback, $ERR_SERVER_NOT_RUNNING());
return;
}
this[serverSymbol] = undefined;
const connectionsCheckingInterval = this[kConnectionsCheckingInterval];
if (connectionsCheckingInterval) {
connectionsCheckingInterval._destroyed = true;

View File

@@ -0,0 +1,32 @@
const common = require('../common');
const assert = require('assert');
const http = require('http');
const net = require('net');
['on', 'addListener', 'prependListener'].forEach((testFn) => {
let received = '';
const server = http.createServer(function(req, res) {
res.writeHead(200);
res.end();
req.socket[testFn]('data', function(data) {
received += data;
});
server.close();
}).listen(0, function() {
const socket = net.connect(this.address().port, function() {
socket.write('PUT / HTTP/1.1\r\nHost: example.com\r\n\r\n');
socket.once('data', function() {
socket.end('hello world');
});
socket.on('end', common.mustCall(() => {
assert.strictEqual(received, 'hello world',
`failed for socket.${testFn}`);
}));
});
});
});