Permalink
Browse files

test: Update test-http-parser-free to use countdown timer

PR-URL: #17322
Refs: #17169
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information...
daxlab authored and gibfahn committed Nov 26, 2017
1 parent 956198f commit f3c1158f57a86f6b515e0661abda1fc1ad061a87
Showing with 4 additions and 8 deletions.
  1. +4 −8 test/parallel/test-http-parser-free.js
@@ -2,13 +2,15 @@
require('../common');
const assert = require('assert');
const http = require('http');
const Countdown = require('../common/countdown');
const N = 100;
let responses = 0;
const server = http.createServer(function(req, res) {
res.end('Hello');
});
const countdown = new Countdown(N, () => server.close());
server.listen(0, function() {
http.globalAgent.maxSockets = 1;
let parser;
@@ -21,15 +23,9 @@ server.listen(0, function() {
assert.strictEqual(req.parser, parser);
}
if (++responses === N) {
server.close();
}
countdown.dec();
res.resume();
});
})(i);
}
});
process.on('exit', function() {
assert.strictEqual(responses, N);
});

0 comments on commit f3c1158

Please sign in to comment.