diff --git a/test/parallel/test-http-1.0.js b/test/parallel/test-http-1.0.js index f9c865f3e630a0..b4cb62534c4f6e 100644 --- a/test/parallel/test-http-1.0.js +++ b/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); - }); + })); }); }