Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: fix http-many-ended-pipelines flakiness
It can happen that the HTTP connection is closed before the server has received
all the requests, thus the server close condition is never reached. To solve
this, close the server when the socket is fully closed.
  • Loading branch information
santigimeno committed Nov 26, 2015
commit d419ee4d949cd8f60913d06cf67d65dc194f61fe
12 changes: 8 additions & 4 deletions test/parallel/test-http-many-ended-pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ var http = require('http');
var net = require('net');

var numRequests = 20;
var done = 0;
var first = false;

var server = http.createServer(function(req, res) {
res.end('ok');
if (!first) {
first = true;
req.socket.on('close', function() {
server.close();
});
}

res.end('ok');
// Oh no! The connection died!
req.socket.destroy();
if (++done == numRequests)
server.close();
});

server.listen(common.PORT);
Expand Down