Skip to content

Commit

Permalink
test: remove timer from test-http-1.0
Browse files Browse the repository at this point in the history
It's possible that the `end` event is emitted after the timeout fires
causing the test to fail. Just remove the timer. If for some reason the
`end` would never fire, the test will fail with a timeout.
  • Loading branch information
santigimeno committed Feb 8, 2016
1 parent 6e3bccb commit d77f305
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions test/parallel/test-http-1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ function test(handler, request_generator, response_validator) {
var client_got_eof = false;
var server_response = '';

function cleanup() {
server.close();
response_validator(server_response, client_got_eof, true);
}
var timer = setTimeout(cleanup, common.platformTimeout(1000));
process.on('exit', cleanup);

server.listen(port);
server.on('listening', function() {
var c = net.createConnection(port);
Expand All @@ -36,14 +29,12 @@ function test(handler, request_generator, response_validator) {
server_response += chunk;
});

c.on('end', function() {
c.on('end', common.mustCall(function() {
client_got_eof = true;
c.end();
server.close();
clearTimeout(timer);
process.removeListener('exit', cleanup);
response_validator(server_response, client_got_eof, false);
});
}));
});
}

Expand Down

0 comments on commit d77f305

Please sign in to comment.