Skip to content
Permalink
Browse files

test: remove timer from test-http-1.0

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.

PR-URL: #5129
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information...
santigimeno authored and Fishrock123 committed Feb 7, 2016
1 parent 70512e5 commit 7c2c7b05770fa71288efe8abf6238506d9fe27fb
Showing with 2 additions and 11 deletions.
  1. +2 −11 test/parallel/test-http-1.0.js
@@ -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);
@@ -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);
});
}));
});
}

0 comments on commit 7c2c7b0

Please sign in to comment.
You can’t perform that action at this time.